You can send API messages through the API Manager without any transformation configurations, if the back-end accepts messages of the same format. For example, the API Manager handles JSON to JSON transformations out of the box. In cases where the back-end does not accept the same format, the transformations are done as described below:
Table of Contents | ||
---|---|---|
|
When a request comes to the API Manager, it sends the response in the same format of the request. For example, the API Manager handles JSON to JSON transformations out of the box. If the backend does not accept messages of the same content type of the request message, it must be transformed to a different format. The API Gateway of the API Manager handles these transformations using message builders and formatters.
When a message comes in to the API Gateway, the receiving transport selects a message builder based on the message's content type. It uses that builder to process the message's raw payload data and convert it into JSON. Conversely, when sending a message out from the Gateway, a message formatter is used to build the outgoing stream from the message. As with message builders, the message formatter is selected based on the message's content type.
Table of Contents | ||
---|---|---|
|
Tip |
---|
Note that if you edit an API's synapse configuration as mentioned in this guide and then go back to the API Publisher and save the API, your changes will be overwritten. As a result, we do not recommend changing the API's synapse configuration directly. The recommended way to extend an API's mediation flow is by engaging |
Also see the following sections in the WSO2 ESB documentation. WSO2 ESB is used to implement the API Gateway through which API messages are transformed:
...
There are two types of message builders and formatters for JSON. The default builder and formatter keep the JSON representation intact without converting it to XML. You can access the payload content using the JSON Path or XPath and convert the payload to XML at any point in the mediation flow.
...
If you want to convert the JSON representation to XML before the mediation flow begins, use the following builder and formatter instead. Note that some data loss can occur during the JSON to -> XML to -> JSON conversion process.
org.apache.synapse.commons.json.JsonBuilder
org.apache.synapse.commons.json.JsonFormatter
The builders and formatters are configured respectively in the messageBuilders
and messageFormatters
sections , respectively, of the Axis2 configuration files located in the <PRODUCT_HOME>/repository/conf/axis2
directory. Both types of JSON builders use StAXON as the underlying JSON processor.
...