Monday, September 1, 2014

How to perform message transformation in WSO2 ESB


Message type transformations are basically done by both Message Builders and Message Formatters.

Their operation can be depicted on following diagram.



According to this image ... 

  • Message builder is chosen based on the content type of incoming message. The chosen builder processes the incoming message's raw payload and converts it in to soap.
  • Message formatter is chosen based on the content type of outgoing message. It builds the output stream based on the content type of message.


messageType” property can be used to change the content-type of the message.

Now Let us look an example scenario...

#1

I am using the postman chrome plug-in as REST client.




The top part represents the JSON request and the bottom part represents the JSON response from the ESB.


#2

I am using the JAX-RS service as my back end server. You can find the code here.


#3

You can find the synapse configuration with transformation details.



You can further improve this synapse configuration by having switch-case, where you can define various builders or formatters based on the content-type of the incoming or outgoing messages.



No comments:

Post a Comment