A way to transform message content in between the client and the backend server - WSO2 Payload Factory Mediator
WSO2 ESB version - 4.0.3
WSO2 PayLoad Factory Mediator is for transforming or replacing message content in between the client and the backend server. Incomming message from client can be transformed by the Payload Factory mediator into the format expected by the service. Then the response message can be formatted into which is expected by the client.
Each argument in the mediator configuration could be a static value or an XPath expression. When an expression is used, argument value is fetched at runtime by evaluating the provided XPath expression against the existing SOAP message. Also the format of the request or response message can be configured which is mapped with the arguments provided in order.
For instance in the following the values for format parameters Code & Price will be assigned with values evaluated from args given in the specified order.
A sample service of WSO2 Payload Factory Mediator can be found from here. The sample mediates the incomming message, send to the server and response is sent back to the client. Inside 'In' mediator, PayloadFactory mediator transforms the message. The response message is transformed inside 'Out' mediator.
We can use PayloadFactory mediator in WSO2 ESB proxy services as well. In the inSequence we can transform the request message, and in outSequence we can transform the response message. Here the publishWSDL must be specified with the WSDL which is visible to the user.
Imagine that there is a web service endpoint which has the getQuote operation with 'symbol' parameter. But client who invokes the service see that there is a getQuote operation with 'Code' parameter. So request message will be sent as,
But server expects a message as,
The PayloadFactory mediator does this transformation as follows.
Similarly the web service will send the response in the format of,
But the client expects the response message as,
So this response message transformation happend on the outSequennce.