Hello
Is there a way to call a c# webservice from java? I have a webservice which was written in c# language and I do want use this webservice in java. If there is a way, please let me know.
Regards Altaico
Hello
Is there a way to call a c# webservice from java? I have a webservice which was written in c# language and I do want use this webservice in java. If there is a way, please let me know.
Regards Altaico
A webservice is just a little program that generates some text, which is then sent by HTTP. The text could by Html or Xml (or plain text). The language that little program is written in is completely irrelevant, since all your Java client will be seeing in text delivered by Http.
Call it exactly as you would call a webservice written in Java or any other language.
The language the webservice is written in should be irrelevant -- that's part of the point of using web services. In general, yes, you can call webservices from Java. One library that can help you with this is Apache Axis.
Web services is a standard protocol. You can call a C# web service the same way you call a Java web service. You can generate a client from the WSDL definition file provided by the service.
From a C# (.NET) web service you can get the WSDL definition file in the following URL:
http://[web_service_virtual_path].asmx?WSDL
I have done this a number of times. Web service support is included in java 1.6 as standard so there are no additional jar files needed.
The starting point is the WSDL url. This looks like a standard HTTP URL with a ?wsdl on the end. As noted by @Germán in his answer it will look something like this:
http://[web_service_virtual_path].asmx?WSDL
The next step is to run wsimport. wsimport is part of the Java 1.6 distribution so no additional downloads are necessary.
I have used the following command from the command line to generate the Java client side code based on the wsdl:
wsimport -s src -keep -Xnocompile http://[web_service_virtual_path].asmx?WSDL
This will create a java package tree in the src folder and leave the .java files there.
(There may be additional flags that need to be set depending on how the actual web service was created or for example you are hiding behind a proxy server. Run wsimport with no parameters to get a list of these flags or options)
The web service documentation (even if it is in C# format) will usually be enough for you to continue writing from this point. This documentation should be available from the writers of the actual web service you are trying to connect to.