views:

224

answers:

5

HI

Could you please give me an idea of how to write a .net web service to call a java web service (written by different person) via SOAP.

Thank you regards Aparna

+1  A: 

For a standard SOAP webservice call, the underlying implementation should not be important to the consuming application. Pull down the WSDL and hope that the calls are documented well enough for you to do what you need to. Be careful with type conversions from another programming language, they may not come over the webservice call exactly like you might expect in the language you use to consume the service.

Chris Ballance
Hi Chris,Thanks for your response.Do you any tutorial for this type of web service, as I am new to web service. Thank youRegardsAparna
A: 

You're simply going to make your .NET service be a client to your Java service:

  1. Right-click your web service project and use "Add Service Reference"
  2. Specify the URL to the WSDL of the Java web service in the "Address" box, then click "Go"
  3. Specify a "Namaespace" through which the Java service will be accessed, for instance "JavaService". Click "Ok".
  4. If everything went well, you should now have a number of classes created for you, under the "YourProjectNamespace.JavaService" namespace.

In particular, you should have one that represents the service itself. Now, a given service may implement more than one service contract (called "port types" in WSDL terms). If the service implements the JavaServiceContract port type, then you should find a class named YourProjectNamespace.JavaService.JavaServiceContractClient. Assuming that this contract includes an operation named "JavaOperation", you should call it like this:

int returnValue = 0;
YourProjectNamespace.JavaService.JavaServiceContractClientjavaService = null;
try {
        javaService = 
            new YourProjectNamespace.JavaService.JavaServiceContractClient();
        returnValue = javaService.JavaOperation();
}
finally {
    if (javaService != null) {
        ((IDisposable)javaService.)Dispose();
    }
}
John Saunders
A: 

Basically calling a java web service in .net web service, .net web app or .net windows application do not have any differece as such. Have a look at this post. Hopefully it will clear all your doubts http://blogs.msdn.com/bursteg/archive/2008/07/19/how-to-call-a-java-ee-web-service-from-a-net-client.aspx

+1  A: 

As with the answers above, it should be straightforward.

The one thing that you need to be careful about is that your exposed Java web service meets the WS-I Basic Profile standards - in other words it needs to use an rpc/literal or document/literal WSDL SOAP binding.

If you are exposing an rpc/encoded web service (which often is the case if you're using Apache Axis as your web services stack), there's a chance you could run into problems trying to consume it from a .NET client.

There's a good article here on WSDL binding styles: http://www.ibm.com/developerworks/webservices/library/ws-whichwsdl/

Chris R
A: 

HI

In the similar situation, how can I send parameters/credentails

Thanks in advance

Jack