【问题标题】:wsimport having problems parsing WSDLwsimport 在解析 WSDL 时遇到问题
【发布时间】: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


【解决方案1】:

我得到它来生成客户端。 WSDL 包含所有系统版本的版本。在 WSDL URL 中传递版本参数将为您提供特定版本。很明显,我在阅读他们的文档时不知何故错过了这一点。

我尝试传递此处提到的 -B-XautoNameResolution 的 JVM 参数 How to use a class customization to resolve file generating conflicts 但这没有用。我找到了一个在线 WSDL 验证网站,发现它缺少太多 XSD 引用,这些都是可用的系统版本。这让我意识到我只需要下载特定版本的 WSDL。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多