我正在使用wsimport为WSO2 webservice(/ services / RemoteUserStoreManagerService?wsdl)生成客户端。
WSO2正在JAVA 6上的单独服务器上运行。
我的问题是当使用JAVA 8生成客户端时。我无法调用Web服务。
JAVA 6
使用JAVA 6时,存根生成和调用工作正常。我通过更改客户端构造函数来接受ULR来动态指定url。
JAVA 8
当使用JAVA 8生成客户端时,我使用默认构造函数(它在静态块中具有硬编码的url)来调用Web服务客户端它工作正常但是对于具有void返回类型的方法给出了下面提到的错误。
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)
但是当我尝试通过使用生成的方法构造函数(URL url)指定WSDL LOCATION来调用客户端时,我得到以下异常:
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)
这是因为WSO2IS正在使用JAVA6而我正在使用JAVA8来调用该服务吗?
我无法理解我哪里出错了。
任何帮助都会感激不尽。
答案 0 :(得分:1)
我终于想到了一些解决方案。可能不是最好的答案,但它仍然解渴了
在为服务创建存根(/ services / RemoteUserStoreManagerService?wsdl)时,我们遇到一些问题,这些方法的返回类型为void:
[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
.....
要解决此问题,我们必须篡改wsdl文件,如下面的链接所示:
Generating stubs with jax-ws fails
http://www.vitharana.org/2015/02/jax-ws-client-for-authenticate-to-wso2.html
另外
这会生成可以同时使用JAVA 6和JAVA 6的存根。 JAVA 8。
现在在JAVA 6中
生成的存根就像JAVA 6中的一块蛋糕一样,因为JAX-WS实现忽略了void方法的(上面添加的)输出标记。
在JAVA 8中
JAX-WS实现不会忽略(上面添加的)输出标记,因此抛出第一个错误
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)
当我们在JAVA 8中使用带有URL的构造函数时,JAX-WS实现尝试直接与WSDL通信。现在由于WSDL没有void方法的输出标记,因此导致第二个错误。
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)
现在,如果您在构造函数中指向修改后的wsdl文件,则会解决错误。
从这一点可以得出结论,JAVA 6到JAVA 8的JAX-WS实现有一些变化,即JAX-WS 2.0到JAX-WS 2.2
答案 1 :(得分:0)
基于WSO2 carbon kernel 4.2.0的产品与Java 8不完全兼容.AFAIK你必须将Java 6与这些产品一起使用。