Cannot configure JAX-WS to configure binding

I am trying to resolve a name conflict in a mapping between wsdl2java and CXF 2.2.6. Relevant wsdl fragments:

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

As you can see, the GetBPK operation accepts the GetBPK input and returns GetBPKResponse as the result. Each element of both GetBPK and GetBPKResponse type will be mapped to a method parameter in Java. Unfortunately, both GetBPK and GetBPKResponse have an element named "PersonInfo", which leads to a name clash.

I am trying to resolve this by setting the binding:

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

and call wsdl2java with the -b option. Unfortunately, I still get the message:

  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.

I tried several options for setting the binding and searched Google for several hours, but, unfortunately, I can not find a solution to my problem.

I suspect that the childElementName attribute is incorrect, but I cannot find an example of what I would need to configure in order for it to work.

BTW, a

 <jaxws:method name="nweMethoName"/> 

instead of <jaxws:parameter.../> works as expected.

Thanks in advance!

+4
source share
3 answers

Try using wsimport with the autoNameResolution parameter?

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

+1
source

I had the same problem, but using -autoNameResolution as a parameter solved the problem.

 wsdl2java -autoNameResolution 
0
source

Source: https://habr.com/ru/post/1304141/