Managing Raw SOAP message within Spring Integration

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.

About these ads

2 thoughts on “Managing Raw SOAP message within Spring Integration

  1. Pingback: Managing Raw SOAP message within Spring Integration – Part 2 | Spring under the hood

  2. Vijay Sathya

    I tried a similar approach to call a web service from http-outbound-gateway. the web service was developed using @endpoint using Sporing-ws. I got error.

    My question is:

    If you had to develop CurrencyConvertor in java using Spring-ws, how will the end point be? Can you post the source code of the service? Thanks.

    Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s