views:

297

answers:

3

I have a WCF web service using wsHttpBinding that I am consuming from a Java client. I generated code from the WSDL using wsimport. The java client appears to be creating the service fine but when I call a method on the service the client just spins.

MyService s = new MyService();
IMyService i = s.getWSHttpBindingIMyService();
returnedValue = i.getSomething(2); // method call

Can a java client communicate with a WCF webservice that is using wsHttpBinding? And what is the best way of doing so?
Any help will be appreciated.

+1  A: 

You may take a look at this link and here's the tutorial.

Darin Dimitrov
Thanks for the tutorial link. That's exactly what I was looking for.
JRP
elduff
A: 

Probably this would help: WCF service & Java client

KMan
+1  A: 

You'll definitely want to use WSIT to help write your client, and it's probably easiest to use the whole Metro stack. Metro contains jaxws-ri, WSIT & JAB in its jars (webservices-rt.jar & webservices-api.jar).

A few steps to get you started:

  1. Does the published WSDL of the WCF service contain a WS-Policy section? If not, get that info & place it into your local local copy of the the service WSDL file. Re-run wsimport on the WSDL containing the WS-Policy section.

  2. Include the metro jars on your client's classpath.

  3. Write a file named wsit-client.xml file & place it into WEB-INF/classes (or on your classpath). Here's a sample. Now, when you use the client, you should see an INFO message in your console that says: WSP5018: Loaded WSIT configuration from file:

  4. If you get stuck on WS-Policy or wsit-client.xml, use Netbeans. I use Eclipse for development, and while I don't really like Netbeans, I've used it as a reference a number of times, because it has configuration settings in the IDE that will enable you to secure web services & write a web service client that needs security, and it'll generate wsit-client.xml & WSDLs with WS-Policy info in them for you. Try writing a web application in Netbeans & pointing to the service's WSDL to generate a web service client there & see what the resulting files look like.

  5. You can get some questions answered here on SO, but the java.net Metro forum is also pretty active, and you can get good support there as well. Just be prepared for answers like "do XYZ in Netbeans/Glassfish".

elduff