Skip to main content

Problems with Java client and Microsoft.NET WCF web services

2 replies [Last post]
vslapp
Offline
Joined: 2012-02-03
Points: 0

I have not been able to get my very simply Java client to successfully call a WCF web service.

I have read over the last several days that using the wshttpbinding should allow java to correctly communicate with WCF, but here is what I am seeing. I can consume the web service, enumerate the methods... but when I call the service (using the code below), the call simply hangs.

Code (generated by Netbeans):
verysimpleapp.SimpleWcfJava service = new verysimpleapp.SimpleWcfJava();
verysimpleapp.ISimpleWcfJava port = service.getWshttpJava();
verysimpleapp.JOptionPane.showMessageDialog(this, port.establishSessionJava());

During runtime:
Feb 05, 2012 8:58:38 PM [com.sun.xml.ws.policy.jaxws.PolicyConfigParser] parse
INFO: WSP5018: Loaded WSIT configuration from file: file:/C:/Users/Administrator/Documents/NetBeansProjects/verysimpleapp/build/classes/META-INF/wsit-client.xml.

During the build, I receive the following warning:
parsing WSDL...
[WARNING] SOAP port "wshttp_java": uses a non-standard SOAP 1.2 binding.
line 1 of file:/C:/Users/Administrator/Documents/NetBeansProjects/verysimpleapp/xml-resources/web-service-references/SimpleWcfJava/wsdl/192.168.2.218_8001/SimpleWcfJava.wsdl

generating code...
verysimpleapp\EstablishSessionJava.java
verysimpleapp\EstablishSessionJavaResponse.java
verysimpleapp\ISimpleWcfJava.java
verysimpleapp\ObjectFactory.java
verysimpleapp\SimpleWcfJava.java
verysimpleapp\package-info.java
Copying 6 files to C:\Users\Administrator\Documents\NetBeansProjects\verysimpleapp\build\generated-sources\jax-ws
wsimport-client-generate:
BUILD SUCCESSFUL (total time: 1 second)

If anyone could offer a solution to this issue.... It would be greatly appreciated.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
vslapp
Offline
Joined: 2012-02-03
Points: 0

So I have some more updates... I feel compelled to post this because it has been anything but a good experience with java/metro/web services/etc... and if most people are having the problem I am having with this... it is amazing anything gets developed on java (for web services specifically).

I did finally get the wsHttpBinding to work as well... the following is my wshttpbinding config:

<wsHttpBinding>
<binding name="WsHttpBinding_java" openTimeout="00:10:00" closeTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" messageEncoding="Text" textEncoding="utf-8" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
<reliableSession enabled="true" ordered="true" />
<security mode="None" />
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
<!--<security mode="Message">
<message clientCredentialType="None" negotiateServiceCredential="false"/>
</security>-->
</binding>
</wsHttpBinding>

But here is the issue... when I compile the project... sometimes the web service method calls works... sometimes they do nothing at all... for example, a simple method that passes two numbers (1 and 1) to an addMethod, will return the value 2. Then if I recompile, the web service will return nothing. No exceptions, errors, warnings.... it is like the call didn't even happen (the debugger says everything is running, but it appears hung).

Then I will delete the META-INF references and the jax-ws generated source files, recompile and run and it will be fine.

Not sure if Java or Netbeans is the issue... but the experience is inconsistent. This make development and troubleshooting extremely difficult since it appears the conditions are changing all the time.

In either case, I was able to get the web service to return data and the project works... but it is a crap shoot at compile time.

Also, I am using Metro 2.1.1 files, not the NetBeans forced "Metro 2.0" library. It is strange that NetBeans only recognizes Metro 2.0 in the library updater... I have to manually force NetBeans to use Metro 2.1.1 files by adding the JAR files manually to the project.

Anyways, I wanted to put this out there in case anyone else is having simliar woes with this.

vslapp
Offline
Joined: 2012-02-03
Points: 0

OK.... I finally figured this out... actually the guy who wrote this article did. So here it is all you .NETers... you can't successfully connect Java to WCF services without the items mentioned in this article.

http://webservices20.blogspot.com/

Mainly the "WCF Express Interop Bindings", found here: http://wcf.codeplex.com/releases/view/68276.

Install this into Visual Studio and it will provide a wizard (along with an interop library) that will allow proper communications to occur between WCF web services and Metro (among others).