【发布时间】:2018-08-10 02:25:55
【问题描述】:
我正在尝试通过使用此处https://gpcs.3m.com/Gpcs/ClaimProcessingService?wsdl 的 wsimport 解析 WSDL 文件来生成 java 客户端,但无法正常工作。
我在 Windows 中使用 JDK8。以下是详细信息。我正在使用 JVM 参数来解决这样的问题 WebService Client Generation Error with JDK8
C:\workspace\client\src>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 只是有错误。我可能错了,但我相信 .Net 很乐意容忍这些错误,这表明 WSDL 是在编写时仅考虑 .Net 而不是符合规范。
标签: java web-services soap jax-ws