【问题标题】:Can't get JAX-WS binding customization to work无法使 JAX-WS 绑定自定义工作
【发布时间】:2010-03-15 12:37:57
【问题描述】:

我正在尝试使用 CXF 2.2.6 解决 wsdl2java 映射中的名称冲突相关的 wsdl sn-ps 是:

<types>...
<xs:schema...
    <xs:element name="GetBPK">
            <xs:complexType>
                <xs:sequence>
                    <xs:element name="PersonInfo" type="szr:PersonInfoType" />
                    <xs:element name="BereichsKennung" type="xs:string" />
                    <xs:element name="VKZ" type="xs:string" />
                    <xs:element name="Target" type="szr:FremdBPKRequestType" minOccurs="0" maxOccurs="unbounded" />
                    <xs:element name="ListMultiplePersons" type="xs:boolean" minOccurs="0" />
                </xs:sequence>
            </xs:complexType>
        </xs:element>
        <xs:element name="GetBPKResponse">
            <xs:complexType>
                <xs:sequence>
                    <xs:element name="GetBPKReturn" type="xs:string" minOccurs="0" />
                    <xs:element name="FremdBPK" type="szr:FremdBPKType" minOccurs="0" maxOccurs="unbounded" />
                    <xs:element name="PersonInfo" type="szr:PersonInfoType" minOccurs="0" maxOccurs="5" />
                </xs:sequence>
            </xs:complexType>
        </xs:element>
</xs:schema>
</types>

<message name="GetBPKRequest">
    <part name="parameters" element="szr:GetBPK" />
</message>
<message name="GetBPKResponse">
    <part name="parameters" element="szr:GetBPKResponse" />
</message>

<binding...
    <operation name="GetBPK">
        <wsdlsoap:operation soapAction="" />
        <input name="GetBPKRequest">
            <wsdlsoap:header message="szr:Header" part="SecurityHeader" use="literal" />
            <wsdlsoap:body use="literal" />
        </input>
        <output name="GetBPKResponse">
            <wsdlsoap:body use="literal" />
        </output>
        <fault name="SZRException">
            <wsdlsoap:fault use="literal" name="SZRException" />
        </fault>
    </operation>

如您所见,GetBPK 操作将 GetBPK 作为输入并返回 GetBPKResponse 作为输出。 GetBPK 以及 GetBPKResponse 类型的每个元素都将映射到 Java 中的方法参数。不幸的是,GetBPK 和 GetBPKResponse 都有一个名为“PersonInfo”的元素,这会导致名称冲突。

我正在尝试使用绑定自定义来解决这个问题:

<jaxws:bindings wsdlLocation="SZ2-aktuell.wsdl"
    xmlns:jaxws="http://java.sun.com/xml/ns/jaxws" xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:jxb="http://java.sun.com/xml/ns/jaxb" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
    xmlns:szr="urn:SZRServices">
    <jaxws:bindings
        node="wsdl:definitions/wsdl:portType[@name='SZR']/wsdl:operation[@name='GetBPK']">
         <!-- See page 116 of the JAX-WS specification version 2.2 from 10, Dec 2009 -->
        <jaxws:parameter
            part="wsdl:definitions/wsdl:message[@name='GetBPKResponse']/wsdl:part[@name='parameters']"
            childElementName="szr:PersonInfoType" name="PersonInfoParam" />

    </jaxws:bindings>
</jaxws:bindings>

并使用 -b 参数调用 wsdl2java。不幸的是,我仍然收到消息:

WSDLToJava 错误:参数:方法 getBPK 的 personInfo 已存在,但类型为 at.enno.egovds.szr.PersonInfoType 而不是 java.util.List。使用 JAXWS/JAXB 绑定定制来重命名参数。

我尝试了几种绑定自定义的变体,并在 Google 上搜索了几个小时,但不幸的是我找不到解决问题的方法。

我怀疑 childElementName 属性是错误的,但我找不到一个示例来说明必须设置什么才能使其工作。

顺便说一句,一个

<jaxws:method name="nweMethoName"/>

而不是&lt;jaxws:parameter.../&gt;,按预期工作。

提前致谢!

【问题讨论】:

    标签: java web-services binding jax-ws customization


    【解决方案1】:

    尝试使用带有 autoNameResolution 参数的 wsimport 吗?

    http://java.net/jira/browse/JAX_WS-228

    【讨论】:

      【解决方案2】:

      我遇到了同样的问题,但是使用 -autoNameResolution 作为参数解决了这个问题。

      wsdl2java -autoNameResolution
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2010-11-04
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-03-15
        • 1970-01-01
        相关资源
        最近更新 更多