Creating new content
In this use case, the message doesn't have a current payload, and we need to create the content of the message. We can affront this use case when we have a REST service that is only triggered with the URL endpoint with the parameters, but also needs a payload to consume a backend service. Another use case can be the inverse process, in which the backend service doesn't have a response, but our service needs to reply with a message for the client that makes the request.
In both scenarios, we can use different WSO2 tools, such as PayloadFactory mediator, Enrich mediator, or Script mediator, although the most simple and easy to use is the PayloadFactory mediator.
The PayloadFactory mediator
The PayloadFactory mediator defines new content for the payload, configuring a template of the new message inside the <format>
tag and the dynamic values inside the <args>
tag.
Here's the syntax:
Here, keep the following in mind:
media-type
is an attribute that defines the format...