prophet4955
prophet4955

Reputation: 5

How to set SOAP Envelope Header in Spring Integration with data from int-http:inbound-gateway?

I tried to build a simple spring integration project where I get a REST request and convert it to a SOAP request. Something like:

<int-http:inbound-gateway id="rest-inbound-gateway" request-channel="restRequestChannel"
    reply-channel="restOutputChannel" supported-methods="POST"
    path="/somepath" request-payload-type="com.something.RequestObject">
        <int-http:request-mapping consumes="application/json" produces="application/json" />
</int-http:inbound-gateway>

<int:transformer ref="RestToSoapTransformer" method="transform"
                 input-channel="restRequestChannel" output-channel="transformedChannel"/>

<int-ws:outbound-gateway id="marshallingGateway"
    request-channel="transformedChannel" reply-channel="restOutputChannel"
    uri="http://localhost:8088/mockSoapBinding" marshaller="marshaller"
    message-sender="messageSender"
    unmarshaller="marshaller" >
</int-ws:outbound-gateway>

But some informations which are in the REST request need to put to the SAOP envelope header and not the envelope body. Eg.

REST Request:

{
    "foo": "foo",
    "bar": "bar"
}

And SOAP Request sould be:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
    <soapenv:Header>
        <foo>foo</foo>
    </soapenv:Header>
    <soapenv:Body>
         <bar>bar</bar>
    </soapenv:Body>
</soapenv:Envelope>

How can I do that? The transformer only create the soap body, and the in an interceptor or header mapper I don't have the original request anymore. Is there any way to do that?

Upvotes: 0

Views: 734

Answers (1)

Gary Russell
Gary Russell

Reputation: 174554

See the documentation.

WS Message Headers

The Spring Integration WebService Gateways will map the SOAP Action header automatically. It will be copied by default to and from Spring Integration MessageHeaders using the DefaultSoapHeaderMapper.

Of course, you can pass in your own implementation of SOAP specific header mappers, as the gateways have respective properties to support that.

Any user-defined SOAP headers will NOT be copied to or from a SOAP Message, unless explicitly specified by the requestHeaderNames and/or replyHeaderNames properties of the DefaultSoapHeaderMapper.

...

Upvotes: 1

Related Questions