【问题标题】:wsimport: class customization bindings when generating a Java SOAP clientwsimport:生成 Java SOAP 客户端时的类自定义绑定
【发布时间】:2014-05-12 15:20:37
【问题描述】:

我正在尝试使用“wsimport”为这个 WebService 生成一个 Java SOAP 客户端:

https://mutalyzer.nl/services/?wsdl

我收到一个错误,因为有两个名为“transcriptInfo”和“TranscriptInfo”的节点:

[错误] 同名“nl.mutalyzer._2_0.services.TranscriptInfo”的类/接口已在使用中。使用类自定义来解决此冲突。 https://mutalyzer.nl/services/?wsdl的第 2 行

我用了wsimport参数-B-XautoNameResolution还是不行:

[错误] 两个声明导致 ObjectFactory 类中的冲突。 第 2 行 ...

我正在尝试进行类自定义。我正在使用一个名为“nameCorrections.xml”的绑定文件,其中包含:

<jaxws:bindings
    wsdlLocation="https://mutalyzer.nl/services/?wsdl"
    xmlns:xs="http://www.w3.org/2001/XMLSchema" 
    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" 
    xmlns:jaxws="http://java.sun.com/xml/ns/jaxws">
    <jaxws:bindings node="wsdl:definitions/wsdl:types/xs:schema/xs:complexType[@name='transcriptInfo']">
        <jaxws:class name="TranscriptInfoByNM"/>
    </jaxws:bindings>
</jaxws:bindings>

它不工作,当我运行时:

wsimport -b nameCorrections.xml http...(WDSL URL,我不能发布两个以上的链接)

我收到了这个错误:

[警告] s4s-elt-invalid-content.1:“transcriptInfo”的内容无效。元素“绑定”无效、放错位置或过于频繁地出现。 线 ? htt.... 我究竟做错了什么?

【问题讨论】:

    标签: java soap wsdl wsimport


    【解决方案1】:

    看来我应该使用“jaxb”绑定而不是“jaxws”绑定。最后,我让 wsimport 可以正常使用这个绑定文件:

    <jaxws:bindings
    wsdlLocation="https://mutalyzer.nl/services/?wsdl"
    xmlns:xs="http://www.w3.org/2001/XMLSchema" 
    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" 
    xmlns:jaxws="http://java.sun.com/xml/ns/jaxws"
    xmlns:jaxb="http://java.sun.com/xml/ns/jaxb">
    <jaxws:bindings node="wsdl:definitions/wsdl:types/xs:schema">
        <jaxb:bindings node="//xs:complexType[@name='transcriptInfo']">
            <jaxb:class name="TranscriptInfoByNM"/>
        </jaxb:bindings>
        <jaxb:bindings node="//xs:element[@name='transcriptInfo']">
            <jaxb:class name="ElementTranscriptInfoByNM"/>
        </jaxb:bindings>
    </jaxws:bindings>
    

    【讨论】:

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