0

我正在一个 WSDL 中创建一个单向操作,该操作具有其他几个工作的双向(请求/响应)操作。

通过 maven 使用 wsdl2java 生成代码失败并出现以下错误:

[ERROR] Failed to execute goal org.apache.cxf:cxf-codegen-plugin:2.7.3:wsdl2java (default) on project mft-shared-ws: Execution default of goal org.apache.cxf:cxf-codegen-plugin:2.7.3:wsdl2java failed:
[ERROR] Summary:  Failures: 1, Warnings: 0
[ERROR] 
[ERROR] <<< ERROR!
[ERROR] file:/C:/workspace/.../ConfigMgr.wsdl:[270,7]
[ERROR] Caused by {http://mydomain.com/configmgr/ws}[portType:ConfigMgrPortType][operation:sendFileTransferEventNotification][input:fileTransferEventNotification] not exist.
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.cxf:cxf-codegen-plugin:2.7.3:wsdl2java (default) on project mft-shared-ws: Execution default of goal org.apache.cxf:cxf-codegen-plugin:2.7.3:wsdl2java failed: 
 Summary:  Failures: 1, Warnings: 0

 <<< ERROR! 
file:/C:/workspace/.../ConfigMgr.wsdl:[270,7] 
 Caused by {http://mydomain.com/configmgr/ws}[portType:ConfigMgrPortType][operation:sendFileTransferEventNotification][input:fileTransferEventNotification] not exist.


    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:225)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
    at org.codehaus.classworlds.Launcher.main(Launcher.java:47)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Caused by: org.apache.maven.plugin.PluginExecutionException: Execution default of goal org.apache.cxf:cxf-codegen-plugin:2.7.3:wsdl2java failed: 
 Summary:  Failures: 1, Warnings: 0

 <<< ERROR! 
file:/C:/workspace/.../ConfigMgr.wsdl:[270,7] 
 Caused by {http://mydomain.com/configmgr/ws}[portType:ConfigMgrPortType][operation:sendFileTransferEventNotification][input:fileTransferEventNotification] not exist.


    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:110)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
    ... 25 more
Caused by: org.apache.cxf.tools.common.ToolException: 
 Summary:  Failures: 1, Warnings: 0

 <<< ERROR! 
file:/C:/workspace/.../ConfigMgr.wsdl:[270,7] 
 Caused by {http://mydomain.com/configmgr/ws}[portType:ConfigMgrPortType][operation:sendFileTransferEventNotification][input:fileTransferEventNotification] not exist.


    at org.apache.cxf.tools.validator.internal.WSDL11Validator.isValid(WSDL11Validator.java:139)
    at org.apache.cxf.tools.wsdlto.frontend.jaxws.wsdl11.JAXWSDefinitionBuilder.validate(JAXWSDefinitionBuilder.java:204)
    at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.processWsdl(WSDLToJavaContainer.java:182)
    at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.execute(WSDLToJavaContainer.java:142)
    at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.execute(WSDLToJavaContainer.java:300)
    at org.apache.cxf.tools.common.toolspec.ToolRunner.runTool(ToolRunner.java:103)
    at org.apache.cxf.tools.wsdlto.WSDLToJava.run(WSDLToJava.java:113)
    at org.apache.cxf.tools.wsdlto.WSDLToJava.run(WSDLToJava.java:86)
    at org.apache.cxf.maven_plugin.wsdl2java.WSDL2JavaMojo.generate(WSDL2JavaMojo.java:427)
    at org.apache.cxf.maven_plugin.AbstractCodegenMoho.execute(AbstractCodegenMoho.java:308)
    at org.apache.cxf.maven_plugin.wsdl2java.WSDL2JavaMojo.execute(WSDL2JavaMojo.java:524)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
    ... 26 more

如果我从 wsdl:input 元素中删除 name 属性,则生成完成。但是,不会触发服务器代码实现。

XSD:

...
<xsd:element name="FileTransferEventNotification" type="tns:FileTransferEvent"/>
<xsd:complexType name="FileTransferEvent">
  <xsd:sequence>
    <xsd:element name="success" type="xsd:boolean" />
    <xsd:element name="filename" type="xsd:string"/>
    <xsd:element name="fileSize" type="xsd:unsignedLong"/>
  </xsd:sequence>
</xsd:complexType>
...

WSDL:

  <wsdl:message name="fileTransferEventNotification">
    <wsdl:part name="fileTransferEventNotification" element="tns:FileTransferEventNotification" />
  </wsdl:message>

  ...

  <wsdl:portType name="ConfigMgrPortType">
    <wsdl:operation name="sendFileTransferEventNotification">
      <wsdl:input message="tns:fileTransferEventNotification" />
    </wsdl:operation>
    ...
  </wsdl:portType>

  ...

  <wsdl:binding name="ConfigMgrSoapBinding" type="tns:ConfigMgrPortType">
    <wsdl:operation name="sendFileTransferEventNotification">
      <soap:operation soapAction="" style="document"/>
      <wsdl:input name="fileTransferEventNotification">
        <soap:body use="literal"/>
      </wsdl:input>
    </wsdl:operation>
    ...
  </wsdl:binding>

有什么想法吗?帮助表示赞赏!

4

1 回答 1

0

事实证明,portType/operation 中的输入消息需要一个名称属性。对于同一 WSDL 中的请求/响应调用,情况似乎并非如此。

WSDL:

  <wsdl:message name="fileTransferEventNotification">
    <wsdl:part name="fileTransferEventNotification" element="tns:FileTransferEventNotification" />
  </wsdl:message>

  ...

  <wsdl:portType name="ConfigMgrPortType">
    <wsdl:operation name="sendFileTransferEventNotification">
      <wsdl:input message="tns:fileTransferEventNotification" name="fileTransferEventNotification"/>
    </wsdl:operation>
    ...
  </wsdl:portType>

  ...

  <wsdl:binding name="ConfigMgrSoapBinding" type="tns:ConfigMgrPortType">
    <wsdl:operation name="sendFileTransferEventNotification">
      <soap:operation soapAction="" style="document"/>
      <wsdl:input name="fileTransferEventNotification">
        <soap:body use="literal"/>
      </wsdl:input>
    </wsdl:operation>
    ...
  </wsdl:binding>
于 2013-11-04T18:14:39.400 回答