Consume WCF .svc WebService in Java - c#

I am new to WebServices.
I have created a .NET WebService (WCF service .svc).
I am able to consume this service from a .NET Client application. Here I have added the service via (Add Service Reference) in the .NET Client.
Now I want to consume the .NET service from a Java desktop application.
How do I add the service reference?
How do I consume the service in java?

You can use wsdl2java and pass it the wsdl file and it will automatically generate the whole client so you can communicate with the WebService.
If you are using eclipse you can use this plugin:
wsdl2java eclipse plugin

If this code will work in production, you may also consider REST WCF, which will work with any language that is able to make HTTP request.

Related

What tools/methods are used to consume WCF web services for Android?

I am designing an Android application which is supposed to connect to a server via WCF web service.
I have a WCF web service written in .NET 4.5 and it is a self-hosted web service. It has SOAP endpoint configuration and it is not a very complex service, however it does include some methods which return DTOs (Classes containing lists, other DTOs and value types).
Now the problem I am facing is that I wish to use some sort of tools to consume the web service definition and generate the proxy classes. I have been successful doing this with the help of Eclipse, but the resulting generated code uses alot of external libraries not available within Android.
Now my question is, what are the preferred tools/methods to consume WCF SOAP web services?
I found that using the following tool gave me the best generated code.
https://code.google.com/p/android-ws-client/
I do recommend this tool to anyone looking for consuming a WCF SOAP web service.

Create C# SOAP API Consumable by other Languages

I've been trying to find a tutorial on here, MSDN, and Google on how to implement my own SOAP API. I have an application written in C# that I want to be consumable by PHP so that calls from the web can interact with the application. How do I generate and tie a WSDL file to my application so that it can be communicated with over SOAP calls? Any suggestions?
I think for this you just need to create WCF service in .net that will allow you to consume server from any language.
Create an ASP.Net Web Services .wsdl file to communicate with the various applications. Host the Web Service on windows IIS server and configure the ports accordingly, then you can access the endpoints to whcih ever application you are using, using the address and the web method name.

Web service written in both WCF and Java

Can I write a web service that implements the same methods and returns the same custom objects using both C#/WCF and also Java Web Services? And if so, can I then access the web services using a single web reference but with different addresses?
I'm asking because I have to host a web service that has a GetCitations and GetTerms method for publically exposing our database content. We are on IIS, so I was going to do it with WCF. However, other partners in the project also have to host an equivalent service and they are all Java based.
We are then building a software app that needs to connect to any number of these services (as defined at runtime by a user). I am expecting that we can have one set of classes to connect to these services (but with different endpoitn addresses), but am not sure whether I'm right in expecting this to work.
Is this possible?
And what considerations/restrictions are there?
Thanks.
It shouldn't be a problem, if you make sure that both services have equivalent wsdl files and you use http/soap binding.
I am not sure about using the binary (net.tcp) one with WCF, though. It might be a problem.
One way to do it is to use JAX-WS (Java 6) to expose a method as a web service.
The JAX-WS stack allows for automatically generating the correct WSDL at runtime.
The .NET team can then take that WSDL, and use standard tools to create a mock implementation of that WSDL. This mock implementation is then used as the actual .NET implementation, and you then use standard tools to generate the WSDL for that web service.
You now have to web services with the same semantics each with their own WSDL.
Both Java and .NET can implement a SOAP compliant web service, so the answer is yes, you can write a .NET and a Java webservice that implement the same WSDL.

Wcf proxy generation on windows mobile application

For my mobile app, I used the Add Web References to generate the client proxy to interact with my WCF service.
Then I read somewhere there is an equivalent of SvcUtil for compact framework: NetCFSvcUtil.
Should I be using the NetCFSvcUtil instead of going throught the Add Web References? Or the Add Web References uses NetCFSvcUtil in the background?
Any pros/cons of one or the other?
Add web reference should be old proxy based on ASMX web services whereas NetCFSvcUtil is tool to generate WCF based proxy. For basic web services there is generally no difference - both will work but if you want to use some advanced WCF features available on CF you will have to use NetCFSvcUtil.

Calling ASP.net Web Service from C# Application

I have a question. How can i invoke a web service and get the result from a C# desktop application. I am making a desktop app and I want it to be able to connect to my online ASP.net web services. How is this possible?
In Solution Explorer, right-click your project node and select Add Service Reference.
Enter the URL where your service WSDL is located. This is usually the URL of the service itself.
This generates a strongly-typed proxy class in a new Services References folder in your project.
Write code in your desktop app to instantiate the proxy class and invoke methods on it. The rest works like magic. :)
AB Kolan was also correct, but Add Web Reference uses the old-style web services framework whereas Add Service References uses the new WCF stack. Important note: It is not required that the service itself use WCF for you to use WCF on the client side. WCF on the client is typically the best choice for any service, provided you can take a dependency on .NET 3.0 and above.
Add a Web Reference to the webservice in your Desktop App project reference. Doing so would generate a Proxy for the Webservice called Reference.cs
You can access your webservice using the proxy.
This is possible the same way that you access web services from any other type of application, be it an ASP.NET page, a class library or windows service.
For an explanatory tutorial on the subject, see Accessing a Web Service from a Desktop Application.
Will get help how to create a webservice and consume that service:
http://www.c-sharpcorner.com/UploadFile/0c1bb2/consuming-web-service-in-Asp-Net-web-application/
Thanks

Categories

Resources