Search code examples
springsoapxsdwsdlspring-ws

Spring WS Request endpoint with SOAP header and body


In a project that I'm developing I need to specify a schema that include a request and response, and in the request that has to be a header and a body.

My problem is to generate the wsdl that specify with the header in request. My schema is this:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema targetNamespace="example"
       xmlns:tns="example"
       xmlns:xs="http://www.w3.org/2001/XMLSchema"
       elementFormDefault="qualified">

<xs:element name="ExampleRequestHeader">
    <xs:complexType>
        <xs:sequence>
            <xs:element name="parameter1" type="xs:string" minOccurs="0"/>
        </xs:sequence>
    </xs:complexType>
</xs:element>

<xs:element name="ExampleRequest">
    <xs:complexType>
        <xs:sequence>
            <xs:element name="parameter2" type="xs:string" minOccurs="0"/>
        </xs:sequence>
    </xs:complexType>
</xs:element>

<xs:element name="ExampleResponse">
    <xs:complexType>
        <xs:sequence>
            <xs:element name="parameter3" type="xs:string" minOccurs="0"/>
        </xs:sequence>
    </xs:complexType>
</xs:element>
</xs:schema>

My wsdl is succefully generated, but the header is always ignored.

<wsdl:message name="ExampleResponse">
    <wsdl:part element="tns:ExampleResponse" name="ExampleResponse">
    </wsdl:part>
</wsdl:message>
<wsdl:message name="ExampleRequest">
    <wsdl:part element="tns:ExampleRequest" name="ExampleRequest">
    </wsdl:part>
</wsdl:message>
<wsdl:portType name="example">
    <wsdl:operation name="Example">
        <wsdl:input message="tns:ExampleRequest" name="ExampleRequest">
        </wsdl:input>
        <wsdl:output message="tns:ExampleResponse" name="ExampleResponse">
        </wsdl:output>
    </wsdl:operation>
</wsdl:portType>
<wsdl:binding name="exampleSoap11" type="tns:example">
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
    <wsdl:operation name="Example">
        <soap:operation soapAction=""/>
        <wsdl:input name="ExampleRequest">
            <soap:body use="literal"/>
        </wsdl:input>
        <wsdl:output name="ExampleResponse">
            <soap:body use="literal"/>
        </wsdl:output>
    </wsdl:operation>
</wsdl:binding>

What I have to do to Spring WS assume that a element in the schema is the header of a request? It's possible right?

PS: This is just an example, not the real service names :)


Solution

  • The solution is in this JIRA issue of Spring WS: https://jira.spring.io/browse/SWS-605

    In concrete, the solution is in this maven project https://jira.spring.io/secure/attachment/19345/soapheader.zip created by @ArjenPoutsma