Aparna
Aparna

Reputation:

calling java web service by .net web service

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

Upvotes: 1

Views: 1782

Answers (4)

Chris R
Chris R

Reputation: 833

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/

Upvotes: 1

Verybiztalker
Verybiztalker

Reputation:

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

Upvotes: 0

John Saunders
John Saunders

Reputation: 161773

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();
    }
}

Upvotes: 0

Chris Ballance
Chris Ballance

Reputation: 34337

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.

Upvotes: 1

Related Questions