Can't get JAX-WS binding customization to work

Posted by Florian on Stack Overflow See other posts from Stack Overflow or by Florian
Published on 2010-03-15T12:37:57Z Indexed on 2010/03/15 12:39 UTC
Read the original article Hit count: 663

Hi!

I'm trying to resolve a name clash in a wsdl2java mapping with CXF 2.2.6 The relevant wsdl snippets are:

<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 takes a GetBPK as input and returns a GetBPKResponse as an output. Each element of both the GetBPK, as well as the GetBPKResponse type would be mapped to a method parameter in Java. Unfortunately both GetBPK, as well as the GetBPKResponse have an element with the name "PersonInfo", which results in a name clash.

I'm trying to resolve that using a binding customization:

<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 parameter. Unforunately, 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<at.enno.egovds.szr.PersonInfoType>.  Use a JAXWS/JAXB binding customization to rename the parameter.

I have tried several variants of the binding customization, and searched Google for hours, but unfortunately I cannot find a solution to my problem.

I suspenct that the childElementName attribute is wrong, but I can't find an example of what would have to be set to make it work.

Thanks in advance!

© Stack Overflow or respective owner

Related posts about java

Related posts about jax-ws