Monday, May 11, 2015

How to use the original incoming message to serve 2 different requests in WSO2 ESB



I am going to explain you a typical scenario where you have to manipulate the incoming message
into WSO2 ESB proxy service.

Proxy service is going to receive the following message as a soap request.


This message should be send to two endpoints. Those are
- Student Record department - The entire request message should be send to this endpoint.
- Finance Department - Only interested with contents inside the "Payment" element.

Initially the proxy service is expected to perform the following operation.

Extract the part and create a payload. Then send it to the finance endpoint.

Lately remove the part by applying the xslt operation to it and then you can send it to the Student Records department.




This proxy service performs following operations
  1. Uses Enrich mediator to copy the complete envelope of incoming soap message.
  2. Property mediator extracts the PAYMENT element and child elements.
  3. Extracted Payment element can be used to create a new soap payload by using payload factory.
  4. If this operation is successful we can use the enrich mediator to recreate the payload
  5. On top of this enriched message XSLT mediator can be used to remove the Payment element.
  6. This message now can be send to the endpoint.



The xslt script, that used to remove the Payment can be found here. I have uploaded it to the registry.
Therefore, the proxy can reference to it by using key.







No comments:

Post a Comment