WSO2 ESB/EI/APIM create payloads with SOAP envelope

Chanaka Fernando
WSO2 Best Practices
Jun 13, 2019

--

WSO2 Integration platform allows users to create message payloads within mediation runtime. As an example, if there is a backend which expects a SOAP message which needs to be exposed through a REST API which accepts a JSON payload, WSO2 Integration platform can do the message transformation using Payload Factory mediator. One common requirement in such scenarios is to build an entire SOAP message with the envelope within the PF mediator.

WSO2 Platform

Creating a SOAP message for SOAP 1.1 endpoint

As depicted in the above code example, PF mediator is used to create the message payload. In addition to that, there is an additional property mediator is used to set the correct content-type for the message. This mediator is essential for sending the correct SOAP message to the backend.

Creating a SOAP message for SOAP 1.2 endpoint

Similar to the previous example, in here the namespace is different in the SOAP envelope to reflect that it is a SOAP 12 message. Also, the “messageType” property is set to “application/soap+xml” which is the correct content-type of SOAP 12.

The above code samples should work on both ESB, EI and APIM sequences.

--

--

Chanaka Fernando
WSO2 Best Practices

Writes about Microservices, APIs, and Integration. Author of “Designing Microservices Platforms with NATS” and "Solution Architecture Patterns for Enterprise"