[英]Can't get JAX-WS binding customization to work
我正在嘗試使用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:parameter.../>
,按預期工作。
提前致謝!
嘗試將wsimport與autoNameResolution參數一起使用?
我遇到了同樣的問題,但使用-autoNameResolution作為參數解決了問題。
wsdl2java -autoNameResolution
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.