Question

In my WSDL I have an operation

<wsdl:operation name="theMethod">
    <wsdl:input message="input1" name="input1"></wsdl:input>
    <wsdl:output message="tns:classNumber1" name="classNumber1"></wsdl:output>
</wsdl:operation>

in my xsd, classNumber1 is a complex type and it is a wrapper for another type: classNumber2

<xs:complexType name="classNumber1">
  <xs:sequence>
   <xs:element minOccurs="0" name="arg0" type="tns:classNumber2"/>
  </xs:sequence>
</xs:complexType>

when I generate classes with cxf (I use cxf maven plugin), I expected that theMethod to return a ClassNumber1 but it was a ClassNumber2.

@WebMethod
@ResponseWrapper(localName="classNumber1" , className="com.model.ClassNumber")
public ClassNumber2 theMethod (Input1 input1){
    ...
}

Is there a way to tell cxf to generate the method with the wrapper CLassNumber1. Thanks.

Was it helpful?

Solution

I find the solution in this doc, question "How can I switch my generated web service method calls from wrapper style to non wrapper-style (or vice-versa)?"

The solution to keep wrappers with cxf generation is to add a binding file in the pom.xml:

<defaultOptions>
<bindingFiles>
    <bindingFile>${basedir}/src/main/resources/bindings.xjb</bindingFile>
</bindingFiles>
<noAddressBinding>true</noAddressBinding>
</defaultOptions>

In the binding file you set enableWrapperStyle to false:

<jaxws:bindings
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
    xmlns="http://java.sun.com/xml/ns/jaxws"
    xmlns:jaxws="http://java.sun.com/xml/ns/jaxws">
    <enableWrapperStyle>false</enableWrapperStyle>
</jaxws:bindings>

OTHER TIPS

Based on the information you have provided I have created a basic interface as shown below.

this works as per your expectation.

        <xsd:complexType name="input1">
            <xsd:sequence>
                <xsd:element name="in" type="xsd:string" />
            </xsd:sequence>
        </xsd:complexType>

        <xsd:complexType name="ClassNumber1">
            <xsd:sequence>
                <xsd:element minOccurs="0" name="out" type="tns:ClassNumber2" />
            </xsd:sequence>
        </xsd:complexType>

        <xsd:complexType name="ClassNumber2">
            <xsd:sequence>
                <xsd:element name="out" type="xsd:string" />
            </xsd:sequence>
        </xsd:complexType>
    </xsd:schema>
</wsdl:types>
<wsdl:message name="input1">
    <wsdl:part element="tns:input1" name="parameters" />
</wsdl:message>
<wsdl:message name="ClassNumber1">
    <wsdl:part element="tns:ClassNumber1" name="parameters" />
</wsdl:message>
<wsdl:portType name="NewWSDLFile">
    <wsdl:operation name="NewOperation">
        <wsdl:input message="tns:input1" />
        <wsdl:output message="tns:ClassNumber1" />
    </wsdl:operation>
</wsdl:portType>
<wsdl:binding name="NewWSDLFileSOAP" type="tns:NewWSDLFile">
    <soap:binding style="document"
        transport="http://schemas.xmlsoap.org/soap/http" />
    <wsdl:operation name="NewOperation">
        <soap:operation soapAction="http://www.example.org/NewWSDLFile/NewOperation" />
        <wsdl:input>
            <soap:body use="literal" />
        </wsdl:input>
        <wsdl:output>
            <soap:body use="literal" />
        </wsdl:output>
    </wsdl:operation>
</wsdl:binding>
<wsdl:service name="NewWSDLFile">
    <wsdl:port binding="tns:NewWSDLFileSOAP" name="NewWSDLFileSOAP">
        <soap:address location="http://www.example.org/" />
    </wsdl:port>
</wsdl:service>

Please check <wsdl:output message="tns:ClassNumber1" />

I believe you have given the wrong in your output information in your

<wsdl:message name="ClassNumber1">
            <wsdl:part element="tns:ClassNumber1" name="parameters" />
        </wsdl:message>

Hope this helps.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top