Normalizer Message Transformation Pattern With WSO2 ESB


The Normalizer is used in scenario where ESB has to mediate different types of message formats and get the service of a certain endpoint service which support only a single format of messages. In a business-to-business (B2B) integration scenario it is quite common for an enterprise to receive messages from different business partners. These message may have the same meaning, but follow different formats, depending on the partners’ internal systems and preferences. For example, we built a solution for a pay-per-view provider that has to accept and process viewership information from over 1700 (!) affiliates, most of which did not conform to a standard format.

Therefore ESB needs to identify those formats and send the responses back in the same format. In such case client application and back-end service do not have to worry about message type because Message Builders and Message Formatters in WSO2 ESB do that on behalf of them.

Implementation Using the WSO2 ESB

  • Start the WSO2 ESB with the following configuration
  • Start the Axis2 server and deploy the SimpleStockQuoteService if not already deployed.
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="">

<!-- The proxy service to receive all kinds of messages -->
<proxy name="ServiceProxy" transports="https http" startOnLoad="true" trace="disable">
<log level="full"/>

<!-- Filters incoming JSON messages -->
<filter xmlns:m0="http://services.samples" xpath="//m0:getQuote/m0:request/m0:symbol">
<sequence key="sendSeq"/>
<sequence key="jsonInTransformSeq"/>



<!-- Filters outgoing JSON messages -->
<filter source="get-property('TRANSFORMATION')" regex="JSONtoSOAP">
<property name="messageType" value="application/json" scope="axis2" type="STRING"/>

<log level="full"/>



<localEntry key="in_transform">
<xsl:stylesheet xmlns:xsl=""
exclude-result-prefixes="m0 fn">
<xsl:output method="xml" omit-xml-declaration="yes" indent="yes"/>
<xsl:template match="*">
<xsl:element name="{local-name()}" namespace="http://services.samples">
<xsl:copy-of select="attribute::*"/>

<!-- Transform a JSON message -->
<sequence name="jsonInTransformSeq">
<xslt key="in_transform"/>
<property name="TRANSFORMATION" value="JSONtoSOAP" scope="default" type="STRING"/>
<sequence key="sendSeq"/>

<!-- Normal flow of messages -->
<sequence name="sendSeq">
<address uri="http://localhost:9000/services/SimpleStockQuoteService" format="soap11"/>

<sequence name="fault">
<log level="full">
<property name="MESSAGE" value="Executing default 'fault' sequence"/>
<property xmlns:ns="http://org.apache.synapse/xsd" name="ERROR_CODE" expression="get-property('ERROR_CODE')"/>
<property xmlns:ns="http://org.apache.synapse/xsd" name="ERROR_MESSAGE" expression="get-property('ERROR_MESSAGE')"/>

<sequence name="main">


In the above synapse configuration first filter-out JSON messages to do necessary transformation and then add to the normal message flow since back-end service only know SOAP. In out sequence also it filters the JSON messages separately in-order to do necessary transformation. Major part of these transformation is done at code level. You can test this configuration for JSON, SOAP, POX messages by using sample axis2client shipped with WSO2ESB.


ant stockquote -Dtrpurl=http://localhost:8280/services/ServiceProxy

For POX – In here the XML message contains exactly the format that the service wants. Else you need to use Payload Factory Mediator to create required message from incoming message.

ant stockquote -Dtrpurl=http://localhost:8280/services/ServiceProxy


ant jsonclient -Daddurl=http://localhost:8280/services/ServiceProxy


[1] WSO2 ESB –

[2] ESB Samples –

[3] Normalizer EAI pattern –


Leave a Reply

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

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

Google+ photo

You are commenting using your Google+ 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 )

Connecting to %s