编程语言
首页 > 编程语言> > java – 无法使JAX-WS绑定自定义工作

java – 无法使JAX-WS绑定自定义工作

作者:互联网

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

<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 Error: Parameter: personInfo already exists for method getBPK but of type at.enno.egovds.szr.PersonInfoType instead of java.util.List.  Use a JAXWS/JAXB binding customization to rename the parameter.

我已经尝试了几种绑定自定义的变体,并在Google上搜索了几个小时,但遗憾的是我无法找到解决问题的方法.

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

BTW,a

<jaxws:method name="nweMethoName"/>

而不是< jaxws:参数... />,按预期工作.

提前致谢!

解决方法:

尝试将wsimport与autoNameResolution参数一起使用?

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

标签:java,web-services,binding,customization,jax-ws
来源: https://codeday.me/bug/20190710/1422943.html