gpt4 book ai didi

java - wsimport:生成 Java SOAP 客户端时的类自定义绑定(bind)

转载 作者:塔克拉玛干 更新时间:2023-11-02 19:24:33 24 4
gpt4 key购买 nike

我正在尝试使用“wsimport”为此 Web 服务生成 Java SOAP 客户端:

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

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

[ERROR] A class/interface with the same name "nl.mutalyzer._2_0.services.TranscriptInfo" is already in use. Use a class customization to resolve this conflict. line 2 of https://mutalyzer.nl/services/?wsdl

我使用了 wsimport 参数 -B-XautoNameResolution 但没有起作用:

[ERROR] Two declarations cause a collision in the ObjectFactory class. line 2 of ...

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

<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, I cannot post more than two links)

我遇到了这个错误:

[WARNING] s4s-elt-invalid-content.1: The content of 'transcriptInfo' is invalid. Element 'bindings' is invalid, misplaced, or occurs too often. line ? of htt.... What am I doing wrong?

最佳答案

看来我应该使用“jaxb”绑定(bind)而不是“jaxws”绑定(bind)。最后,我让 wsimport 可以很好地处理这个绑定(bind)文件:

<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>

关于java - wsimport:生成 Java SOAP 客户端时的类自定义绑定(bind),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23612901/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com