3.5 Converting JSON to XML

Secure API Manager allows you to convert the input messages to the APIs, the output of messages of the APIs to the back-end services, or show any exceptions that occur in the APIs from JSON to XML. You would do this if the API was written in XML and the service receiving the message excepts only JSON.

You enable Message Mediation on the Implement page in the Publisher whether you are creating a production API or editing an existing production API.

To enable Message Mediation when editing the API:

  1. Log in to the Publisher using an administrator account.

    https://lifecycle-manager-dns-name:9444/publisher
  2. Find the appropriate API.

  3. Click the Edit icon on the appropriate API to edit the API.

  4. Scroll to the bottom of the page, then click Next: Implement.

  5. Under the heading Message Mediation Policies, click Enable Message Mediation.

  6. Click in the field of the appropriate option for your API.

    Input Flow

    Enable this option by selecting an available file listed when you click in the field or click the Upload icon to upload your own file.

    The Input Flow allows you to take the incoming messages to the API and transform the JSON to XML when the message arrives at the API Gateway. If you want to revert back to XML, remove the file.

    Output Flow

    Enable this option by selecting an available file listed when you click in the field or click the Upload icon to upload your own file.

    The Output Flow allows you to take the messages sent from the API to the back-end services and convert the messages from JSON to XML when the messages hit the API Gateway.

    Fault Flow

    Enable this option by selecting an available file listed when you click in the field or click the Upload icon to upload your own file.

    By default, Secure API Manager writes error logs in XML. If an error occurs in the API, the Fault Flow allows to convert the XML message to JSON and then the API Gateway writes the log in JSON.

  7. At the bottom of the page, click Next: Manage, then scroll the bottom of the next page and click Save and Publish to save the Message Mediation policies.

After you have added the Message Mediation policies to the API, you can test the functionality in the Store through the API Console tab. The API Console tab allows you to test all of the calls in the API individually through the Try Me option on each call.