[WSO2 ESB] Transform Messages with WSO2 XSLT Mediator

Transforming messages is an essential part in enterprise messaging. There are several ways you can transform messages in WSO Enterprise Service Bus (ESB). With this post we try to transform a message using the WSO2 ESB XSLT mediator.

Requirement

The use case is as follows, WSO2 ESB will get a request as shown in “Current Message”. ESB needs to transform this message before sending to the backend service. The backend service require the message to be in “Required Message” format.

Current Message (message received by ESB):

<TRANSACTION>
     <TRANS_TIMESTAMP>1437038356</TRANS_TIMESTAMP>
     <TRANS_ID>TR10035918373588</TRANS_ID>
     <TRANS_TYPE>ONLINE</TRANS_TYPE>
     <BANK_CODE>BNK001</BANK_CODE>
</TRANSACTION>

Required Message (message format required by the backend service):

<BANK_TR>
     <TIMESTAMP>1437038356</TIMESTAMP>
     <TRANSACTION_ID>TR10035918373588</TRANSACTION_ID>
     <TRANSACTION_TYPE>ONLINE</TRANSACTION_TYPE>
     <BANKCODE>BNK001</BANKCODE>
     <PROCESSED>TRUE</PROCESSED>
</BANK_TR>

To make the transformation possible we will be using the WSO2 ESB XSLT mediator. Transformation will be done according to the xslt provided to the service. The xslt should be as follows;
Testing this with WSO2 ESB can be done with a simple proxy service;

Test the transformation by sending the above “Current Message” to the proxy service.

One Reply to “[WSO2 ESB] Transform Messages with WSO2 XSLT Mediator”

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.