Over a million developers have joined DZone.
Platinum Partner

Managing Raw SOAP message within Spring Integration

· Integration Zone

The Integration Zone is brought to you in partnership with 3scale. Take control of your APIs and get a free t-shirt when you complete the 3step Challenge

In Spring Integration if we use int-ws:outbound-gateway, once a message is associated to the request channel, the Spring Integration container add the SOAP header information and sends the SOAP payload to the target system to be processed. Most of the time, this is what is needed, but sometimes, we just need the integration layer to act as a proxy. The SOAP payload coming from the source system is just handed to the target system retaining all the properties of source system like security, enrichment and others.

In this case the trick is instead of using int-ws:outbound-gateway, we should use int-http:inbound-gateway and int-http:outbound-gateway. This way you can fool the target system to accept this as a SOAP message. We can also make it aware what soapAction we need to execute is a below,

<int-http:inbound-gateway id="webservice.inbound.gateway"
request-channel="http.outbound.enrich.in" reply-channel="ws.outbound"
name="/receiveGateway" supported-methods="POST" />

<int:header-enricher input-channel="http.outbound.enrich.in"
output-channel="ws.inbound">
<int:header name="Content-Type" value="text/xml;charset=UTF-8" />
<int:header name="SoapAction"
value="http://www.webserviceX.NET/ConversionRate" />
</int:header-enricher>

<int:channel id="ws.outbound" />

<int-http:outbound-gateway id="webservice.outbound.gateway"
request-channel="ws.inbound" reply-channel="ws.outbound"
url="http://www.webservicex.net/CurrencyConvertor.asmx"
expected-response-type="java.lang.String" />

The Spring Integration flow is as below,

Managing Raw SOAP message within Spring Integration

Managing Raw SOAP message within Spring Integration

I hope this blog helped you.


The Integration Zone is brought to you in partnership with 3scale. Learn how API providers have changed the way we think about integration in The Platform Vision of API Giants.

Topics:

Published at DZone with permission of Krishna Prasad , DZone MVB .

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}