wsimport在解析WSDL时遇到问题
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了wsimport在解析WSDL时遇到问题相关的知识,希望对你有一定的参考价值。
我正在尝试通过使用wsimport从这里https://gpcs.3m.com/Gpcs/ClaimProcessingService?wsdl解析WSDL文件来生成一个java客户端,但是无法正常工作。 我在Windows中使用JDK8。以下是详细信息。我正在使用JVM参数来解决像WebService Client Generation Error with JDK8这样的问题
C:workspaceclientsrc>wsimport -J-Djavax.xml.accessExternalSchema=all -keep https://gpcs.3m.com/Gpcs/ClaimProcessingService?wsdl
[ERROR] Two declarations cause a collision in the ObjectFactory class.
line 1899 of https://gpcs.3m.com/Gpcs/ClaimProcessingService?xsd=gpcs_standard_2016_3_0.xsd
[ERROR] (Related to above error) This is the other declaration.
line 1899 of https://gpcs.3m.com/Gpcs/ClaimProcessingService?xsd=gpcs_standard_2016_3_1.xsd
Exception in thread "main" com.sun.tools.internal.ws.wscompile.AbortException
at com.sun.tools.internal.ws.processor.modeler.wsdl.JAXBModelBuilder.bind(JAXBModelBuilder.java:129)
at com.sun.tools.internal.ws.processor.modeler.wsdl.WSDLModeler.buildJAXBModel(WSDLModeler.java:2283)
at com.sun.tools.internal.ws.processor.modeler.wsdl.WSDLModeler.internalBuildModel(WSDLModeler.java:183)
at com.sun.tools.internal.ws.processor.modeler.wsdl.WSDLModeler.buildModel(WSDLModeler.java:126)
at com.sun.tools.internal.ws.wscompile.WsimportTool.buildWsdlModel(WsimportTool.java:429)
at com.sun.tools.internal.ws.wscompile.WsimportTool.run(WsimportTool.java:190)
at com.sun.tools.internal.ws.wscompile.WsimportTool.run(WsimportTool.java:168)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.sun.tools.internal.ws.Invoker.invoke(Invoker.java:159)
at com.sun.tools.internal.ws.WsImport.main(WsImport.java:42)
我还在本地下载了WSDL文件,并通过删除一些引用来修改它,因为错误太多了,无法看到。当我这样做时,我能够看到下面显示的错误消息的开头
[ERROR] A class/interface with the same name "com._3m.gpcs.standard._2016_0.ClaimErrorType" is already in use. Use a class customization to resolve this conflict.
line 3409 of https://gpcs.3m.com/Gpcs/ClaimProcessingService?xsd=gpcs_standard_2016_0_0.xsd
[ERROR] (Relevant to above error) another "ClaimErrorType" is generated from here.
line 3411 of https://gpcs.3m.com/Gpcs/ClaimProcessingService?xsd=gpcs_standard_2016_0_1.xsd
[ERROR] A class/interface with the same name "com._3m.gpcs.standard._2016_0.ErrorSeverity" is a
lready in use. Use a class customization to resolve this conflict.
line 3473 of https://gpcs.3m.com/Gpcs/ClaimProcessingService?xsd=gpcs_standard_2016_0_0.xsd
任何人都知道为什么这不能生成java代码?我也尝试使用Eclipse创建一个java客户端,但也失败了以下错误。提前致谢。
IWAB0399E Error in generating Java from WSDL: java.io.IOException: WSDL2Java emitter timed out (this often means the WSDL at the specified URL is inaccessible)!
java.io.IOException: WSDL2Java emitter timed out (this often means the WSDL at the specified URL is inaccessible)!
at org.apache.axis.wsdl.gen.Parser.run(Parser.java:320)
at org.apache.axis.wsdl.toJava.Emitter.run(Emitter.java:599)
at org.eclipse.jst.ws.internal.axis.consumption.core.command.WSDL2JavaCommand.execute(WSDL2JavaCommand.java:207)
at org.eclipse.jst.ws.internal.axis.consumption.ui.task.ClientCodeGenOperation$ClientWSModifyOperation.execute(ClientCodeGenOperation.java:144)
at org.eclipse.ui.actions.WorkspaceModifyOperation$1.run(WorkspaceModifyOperation.java:108)
at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2241)
at org.eclipse.ui.actions.WorkspaceModifyOperation.run
我得到它来生成客户端。 WSDL包含所有系统版本的版本。在WSDL URL中传递版本参数将为您提供特定版本。很明显,我在阅读他们的文档时错过了这一点。
我尝试传递一个JVM参数-B-XautoNameResolution,这里提到How to use a class customization to resolve file generating conflicts,但是没有用。我找到了一个在线WSDL验证网站,发现它缺少太多的XSD引用,这些引用都是系统的可用版本。这让我意识到我只需要为特定版本下载WSDL。
以上是关于wsimport在解析WSDL时遇到问题的主要内容,如果未能解决你的问题,请参考以下文章
使用java的wsimport.exe生成wsdl的客户端代码
JDK Tools - wsimport: 编译 WSDL 生成 JAX-WS 规范的 Java 类