Search code examples
soapwsdljax-ws

How to have a wsdl conform to the soap input


We are changing our soap webservices from jetty to jaxws. The goal is to keep the same input message. I have used the original WSDL to create the service with netbeans. The WSDL is the following:

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="http://www.mycompany.nl/DcxExpeditieService/v1"
        xmlns:tns="http://www.mycompany.nl/DcxExpeditieService/v1"
        xmlns:xs="http://www.w3.org/2001/XMLSchema"
        xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
        xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
    <wsdl:types>
        <xs:schema targetNamespace="http://www.mycompany.nl/DcxExpeditieService/v1"
                xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
            <xs:element name="DcxExpeditie" type="tns:DcxExpeditie"/>
            <xs:complexType name="DcxExpeditie">
                <xs:sequence>
                    <xs:element name="Expeditie" type="tns:Expeditie"/>
                </xs:sequence>
            </xs:complexType>
            <xs:complexType name="Expeditie">
                <xs:sequence>
                    <xs:element name="tag1" type="xs:string"/>
                    <xs:element name="tag2" type="xs:string"/>
                </xs:sequence>
            </xs:complexType>
        </xs:schema>
    </wsdl:types>
    <wsdl:message name="DcxExpeditieRequest">
        <wsdl:part name="DcxExpeditie" type="tns:DcxExpeditie"/>
    </wsdl:message>
    <wsdl:message name="DcxExpeditieResponse">
        <wsdl:part name="DcxExpeditieResponse" type="xs:string"/>
    </wsdl:message>
    <wsdl:portType name="DcxExpeditieServicePortType">
        <wsdl:operation name="DcxExpeditieOperation">
            <wsdl:input message="tns:DcxExpeditieRequest"/>
            <wsdl:output message="tns:DcxExpeditieResponse"/>
        </wsdl:operation>
    </wsdl:portType>
    <wsdl:binding name="DcxExpeditieServiceSOAP" type="tns:DcxExpeditieServicePortType">
        <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
        <wsdl:operation name="DcxExpeditieOperation">
            <soap:operation soapAction="http://www.mycompany.nl/DcxExpeditieService/v1/DcxExpeditie"/>
            <wsdl:input>
                <soap:body use="literal" namespace="http://www.mycompany.nl/DcxExpeditieService/v1"/>
            </wsdl:input>
            <wsdl:output>
                <soap:body use="literal" namespace="http://www.mycompany.nl/DcxExpeditieService/v1"/>
            </wsdl:output>
        </wsdl:operation>
    </wsdl:binding>
    <wsdl:service name="DcxExpeditieService">
        <wsdl:port name="DcxExpeditieServiceSOAP" binding="tns:DcxExpeditieServiceSOAP">
            <soap:address location="https://someserver.mycompany.nl/vbs/dcxexpeditie"/>
        </wsdl:port>
    </wsdl:service>
</wsdl:definitions>

When using this WSDL in soapui it results in the following input example:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v1="http://www.mycompany.nl/DcxExpeditieService/v1">
   <soapenv:Header/>
   <soapenv:Body>
      <v1:DcxExpeditieOperation>
         <DcxExpeditie>
            <v1:Expeditie>
               <v1:tag1>?</v1:tag1>
               <v1:tag2>?</v1:tag2>
            </v1:Expeditie>
         </DcxExpeditie>
      </v1:DcxExpeditieOperation>
   </soapenv:Body>
</soapenv:Envelope>

However, the original input format was:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v1="http://www.mycompany.nl/DcxExpeditieService/v1">
       <soapenv:Header/>
       <soapenv:Body>
          <v1:DcxExpeditie>
                <v1:Expeditie>
                   <v1:tag1>?</v1:tag1>
                   <v1:tag2>?</v1:tag2>
                </v1:Expeditie>
          </v1:DcxExpeditie>
       </soapenv:Body>
    </soapenv:Envelope>

so with no DcxExpeditieOperation tag and with the v1 namespace in front of DcxExpeditie

Is this possible and if so, how can I accomplish this?


Solution

  • Try to change SOAP binding from rpc to document to remove DcxExpeditieOperation tag:

    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
    

    To fix the namespace issue refer DcxExpeditie element insted of type:

    <wsdl:part name="DcxExpeditie" element="tns:DcxExpeditie"/>
    

    Updated WSDL file:

    <?xml version="1.0" encoding="UTF-8"?>
    <wsdl:definitions targetNamespace="http://www.mycompany.nl/DcxExpeditieService/v1"
                      xmlns:tns="http://www.mycompany.nl/DcxExpeditieService/v1"
                      xmlns:xs="http://www.w3.org/2001/XMLSchema"
                      xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
                      xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
        <wsdl:types>
            <xs:schema targetNamespace="http://www.mycompany.nl/DcxExpeditieService/v1"
                               xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
                <xs:element name="DcxExpeditie" type="tns:DcxExpeditie"/>
                <xs:element name="DcxExpeditieResponse" type="xs:string"/>
                <xs:complexType name="DcxExpeditie">
                    <xs:sequence>
                        <xs:element name="Expeditie" type="tns:Expeditie"/>
                    </xs:sequence>
                </xs:complexType>
                <xs:complexType name="Expeditie">
                    <xs:sequence>
                        <xs:element name="tag1" type="xs:string"/>
                        <xs:element name="tag2" type="xs:string"/>
                    </xs:sequence>
                </xs:complexType>
            </xs:schema>
        </wsdl:types>
        <wsdl:message name="DcxExpeditieRequest">
            <wsdl:part name="DcxExpeditie" element="tns:DcxExpeditie"/>
        </wsdl:message>
        <wsdl:message name="DcxExpeditieResponse">
            <wsdl:part name="DcxExpeditieResponse" element="tns:DcxExpeditieResponse" />
        </wsdl:message>
        <wsdl:portType name="DcxExpeditieServicePortType">
            <wsdl:operation name="DcxExpeditieOperation">
                <wsdl:input message="tns:DcxExpeditieRequest"/>
                <wsdl:output message="tns:DcxExpeditieResponse"/>
            </wsdl:operation>
        </wsdl:portType>
        <wsdl:binding name="DcxExpeditieServiceSOAP" type="tns:DcxExpeditieServicePortType">
            <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
            <wsdl:operation name="DcxExpeditieOperation">
                <soap:operation soapAction="http://www.mycompany.nl/DcxExpeditieService/v1/DcxExpeditie"/>
                <wsdl:input>
                    <soap:body use="literal" />
                </wsdl:input>
                <wsdl:output>
                    <soap:body use="literal" />
                </wsdl:output>
            </wsdl:operation>
        </wsdl:binding>
        <wsdl:service name="DcxExpeditieService">
            <wsdl:port name="DcxExpeditieServiceSOAP" binding="tns:DcxExpeditieServiceSOAP">
                <soap:address location="https://someserver.mycompany.nl/vbs/dcxexpeditie"/>
            </wsdl:port>
        </wsdl:service>
    </wsdl:definitions>