Welcome to Jacksonville Developers User Group Sign in | Join | Help

Trouble with Java clients consuming a WCF service?

I was tasked with making a java client utilize a WCF service. 

The details:

  • JDK/JRE 1.6
  • NetBeans 6/JAXWS
  • .NET 3.0
  • WCF

It is obvious per the title of this post that the communication did not work out of the box.  There was nothing special I did on Java’s side.  Rather I became more familiar with the default behavior of WCF.  Such as the default message version (SOAP version) for WCF, this is defined as WS-Addressing 1.0 and SOAP 1.2.  Now, the default for JAXWS is SOAP 1.1.  So right there you see where a problem can arise between these two technologies. 

My resolution was to edit the WCF host configuration to provide SOAP 1.0 support like so:

<bindings>

  <customBinding>

    <binding name="Soap11Binding">

      <textMessageEncoding messageVersion="Soap11" />

      <httpTransport />

    </binding>

  </customBinding>

</bindings>

Now what I have done with the above configuration is create a custom binding to support clients that are not currently able to (or refuse to) take advantage of SOAP 1.2 and WS-Addressing 1.0.

<endpoint

      address="http://localhost/MyHost/MyService.svc"

      binding="customBinding"

      bindingConfiguration="Soap11Binding"

      contract="Services.IMyService" />

 

This is how to utilize the custom binding you have created in your endpoint configuration. 

After much staring out the window, this is the solution I found to make it work.  Notice I did not say I found “the answer”.  I am sure there is another solution out there, but this one worked best for what I was trying to accomplish.  In fact, through my research I noticed that others were attempting to solve this from the Java side by exploring wsgen.exe (i.e. wsgen.exe –extension –wsdl:Xsoap1.2).  I hope others find this post useful.  I did a bit of searching about this topic and did not find enough information in my opinion (I admit my googling is sub-par).  I found a lot of talk and not much doing.   

Is there anyone out there having to communicate with WCF with a non-.NET client?  What difficulties have you discovered in doing so?

Published Monday, January 21, 2008 5:35 PM by tbates
Filed Under: , ,

Comments

# re: Trouble with Java clients consuming a WCF service?

Hi, You seem to do two things here that are little confusing to follow. Initially you say you are writing a client for WCF service, then i don't see why you are using wsgen? wsgen is if you are creating service starting from java. *** JAX-WS does support SOAP 1.2. Did you read the doc @ https://jax-ws.dev.java.net/nonav/2.1.3/docs/soap12.html that explains using SOAP 1.2 Web Services. You may just need to invoke wsimport with -extension option to consume SOAP 1.2 wsdl. You don't need to change bindings for WCF service etc. BTW, if you are using NetBeans, it should have done that automatically. the wsgen switch -wsdl:Xsoap1.2 is if you are starting from Java to create SOAP 1.2 Web Service.
Thursday, January 24, 2008 6:38 PM by Rama

# re: Trouble with Java clients consuming a WCF service?

Rama – And I previously mentioned that the default for JAXWS (more accurately JAX-WS 2.0) is SOAP 1.1, not that it would not support SOAP 1.2. Through my testing Netbeans did not auto-magically recognize that the WCF service was sending SOAP 1.2 and WS-Addressing 1.0 over HTTP. I realize that additional configuration was possible on the Java, but that was not the angle I was looking to solve this from. In addition, my viewpoint was sort of skewed. I was thinking from the point of view as if I was using WCF to replace an existing .NET web service that was not written with WCF. That tidbit might have proven useful during your preview (even though irrelevant). It is good that you bring (what reads like) a Java oriented perspective to the discussion. Thanks for your response.
Monday, January 28, 2008 12:36 PM by tbates
Anonymous comments are disabled