Sudeep
Sudeep

Reputation: 149

Webservice client for Java 6 not working in Java 8

I am using wsimport to generate client for a WSO2 webservice (/services/RemoteUserStoreManagerService?wsdl).

WSO2 is running on a separate server on JAVA 6.

My problem is that when the client is generated using JAVA 8. I am not able to invoke the webservice.

JAVA 6

The stub generation and invocation works fine when JAVA 6 is used. I specify the url dynamically by changing the client constructor to accept ULR.

JAVA 8

When the client is generated using JAVA 8 and I use the default the constructor (It has the url hardcoded in the static block) to invoke the web service client it works fine but gives below mentioned error for methods with void return type.

Exception in thread "main" javax.xml.ws.WebServiceException: No response returned.
at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:98)
at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:77)
at com.sun.xml.internal.ws.client.sei.SEIStub.invoke(SEIStub.java:147)
at com.sun.proxy.$Proxy34.updateRoleListOfUser(Unknown Source)
at com.abc.xyz.portal.service.UserAdminServiceClient.updateUser(UserAdminServiceClient.java:181)
at com.abc.xyz.portal.service.UserAdminServiceClient.main(UserAdminServiceClient.java:192)

But when i try to invoke the client by specifying the WSDL LOCATION using the generated method constructor(URL url) I get below exception:

Exception in thread "main" java.lang.NullPointerException
at com.sun.xml.internal.ws.model.JavaMethodImpl.freeze(JavaMethodImpl.java:379)
at com.sun.xml.internal.ws.model.AbstractSEIModelImpl.freeze(AbstractSEIModelImpl.java:105)
at com.sun.xml.internal.ws.model.RuntimeModeler.buildRuntimeModel(RuntimeModeler.java:320)
at com.sun.xml.internal.ws.db.DatabindingImpl.<init>(DatabindingImpl.java:85)
at com.sun.xml.internal.ws.db.DatabindingProviderImpl.create(DatabindingProviderImpl.java:59)
at com.sun.xml.internal.ws.db.DatabindingProviderImpl.create(DatabindingProviderImpl.java:43)
at com.sun.xml.internal.ws.db.DatabindingFactoryImpl.createRuntime(DatabindingFactoryImpl.java:105)
at com.sun.xml.internal.ws.client.WSServiceDelegate.buildRuntimeModel(WSServiceDelegate.java:875)
at com.sun.xml.internal.ws.client.WSServiceDelegate.createSEIPortInfo(WSServiceDelegate.java:892)
at com.sun.xml.internal.ws.client.WSServiceDelegate.addSEI(WSServiceDelegate.java:855)
at com.sun.xml.internal.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:435)
at com.sun.xml.internal.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:404)
at com.sun.xml.internal.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:386)
at javax.xml.ws.Service.getPort(Service.java:119)
at com.abc.xyz.remoteuserstore.client.RemoteUserStoreManagerService.getRemoteUserStoreManagerServiceHttpsSoap11Endpoint(RemoteUserStoreManagerService.java:72)
at com.abc.xyz.portal.service.UserAdminServiceClient.<init>(UserAdminServiceClient.java:47)
at com.abc.xyz.portal.service.UserAdminServiceClient.main(UserAdminServiceClient.java:190)

Is this because WSO2IS is working on JAVA6 and i am using JAVA8 to invoke the service?

I am not able to understand where am i going wrong.

Any help would be grateful.

Upvotes: 2

Views: 3918

Answers (2)

Sudeep
Sudeep

Reputation: 149

I finally figured some resolutions to my quest. may not be the best answer but still it quenches my thirst

While creating the stubs for the service (/services/RemoteUserStoreManagerService?wsdl) we face some issues with methods which have void as return type:

[ERROR] operation "updateCredential" has an invalid style
  line 721 of file:/G:/agent/RemoteUserService.xml

[ERROR] operation "setUserClaimValue" has an invalid style
  line 725 of file:/G:/agent/RemoteUserService.xml
.....

To resolve this we have to tamper with the wsdl file as mentioned in the links below:

Generating stubs with jax-ws fails

http://www.vitharana.org/2015/02/jax-ws-client-for-authenticate-to-wso2.html

Also

https://briskwalk.wordpress.com/2012/03/30/a-classinterface-with-the-same-name-is-already-in-use-error-when-generating-stubs-for-net-service-using-jdk-6-wsimport-command/

This generates the stubs which can be used both JAVA 6 & JAVA 8.

Now in JAVA 6

The generated stub works like a piece of cake in JAVA 6 as the JAX-WS implementations ignore the (above added) output tag for the void methods.

In JAVA 8

The JAX-WS implementation does not ignore the (above added) output tag and hence throws the first error

Exception in thread "main" javax.xml.ws.WebServiceException: No response returned.
at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:98)
at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:77)
at com.sun.xml.internal.ws.client.sei.SEIStub.invoke(SEIStub.java:147)
at com.sun.proxy.$Proxy34.updateRoleListOfUser(Unknown Source) 
at com.abc.xyz.portal.service.UserAdminServiceClient.updateUser(UserAdminServiceClient.java:181)
at com.abc.xyz.portal.service.UserAdminServiceClient.main(UserAdminServiceClient.java:192)

When we use the constructor with URL in JAVA 8 JAX-WS implementation tries to communicate with the WSDL directly. Now as the WSDL does not have the output tag for the void method it results to cause the second error.

Exception in thread "main" java.lang.NullPointerException
at com.sun.xml.internal.ws.model.JavaMethodImpl.freeze(JavaMethodImpl.java:379)
at com.sun.xml.internal.ws.model.AbstractSEIModelImpl.freeze(AbstractSEIModelImpl.java:105)
at com.sun.xml.internal.ws.model.RuntimeModeler.buildRuntimeModel(RuntimeModeler.java:320)
at com.sun.xml.internal.ws.db.DatabindingImpl.<init>(DatabindingImpl.java:85)
at com.sun.xml.internal.ws.db.DatabindingProviderImpl.create(DatabindingProviderImpl.java:59)
at com.sun.xml.internal.ws.db.DatabindingProviderImpl.create(DatabindingProviderImpl.java:43)
at com.sun.xml.internal.ws.db.DatabindingFactoryImpl.createRuntime(DatabindingFactoryImpl.java:105)
at com.sun.xml.internal.ws.client.WSServiceDelegate.buildRuntimeModel(WSServiceDelegate.java:875)
at com.sun.xml.internal.ws.client.WSServiceDelegate.createSEIPortInfo(WSServiceDelegate.java:892)
at com.sun.xml.internal.ws.client.WSServiceDelegate.addSEI(WSServiceDelegate.java:855)
at com.sun.xml.internal.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:435)
at com.sun.xml.internal.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:404)
at com.sun.xml.internal.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:386)
at javax.xml.ws.Service.getPort(Service.java:119)
at com.abc.xyz.remoteuserstore.client.RemoteUserStoreManagerService.getRemoteUserStoreManagerServiceHttpsSoap11Endpoint(RemoteUserStoreManagerService.java:72)
at com.abc.xyz.portal.service.UserAdminServiceClient.<init>(UserAdminServiceClient.java:47)
at com.abc.xyz.portal.service.UserAdminServiceClient.main(UserAdminServiceClient.java:190)

Now if you point to the modified wsdl file in the constructor the error is resolved.

From this one thing can be concluded that there is some change in the JAX-WS implementations in JAVA 6 to JAVA 8. ie JAX-WS 2.0 to JAX-WS 2.2

Upvotes: 1

WSO2 carbon kernel 4.2.0 based products are not fully compatible with Java 8. AFAIK you have to use Java 6 with those products.

Upvotes: 0

Related Questions