Converting XML Message to JSON Message

By default, TIBCO API Exchange Gateway sends the response message in XML format from the target operation to the client. If a client requests the response message in a JSON format, you can convert the XML message to a JSON message as follows:

    Procedure
  1. Create an XSLT File.

    To create an XSLT file to render the data in JSON format, follow these high level steps:

    Add namespaces:

    The render() function requires the following namespace: http://www.tibco.com/asg/functions/json

    Build JSON structure.
    Use the render() function:

    See Example XSLT to Convert BookQuery XML Response to JSON Response for an example XSLT.

  2. Upload the XSLT File.

    Using the Config UI, upload the XSLT file in the northbound reverse mapper to render the XML response message in JSON message format as follows:

    1. Start the GUI server, if not already running.
    2. Log in to the Config UI using your credentials.
    3. Add a new project or select an existing project under Projects. For example, select BookQuery project.
    4. Add the mapping configuration as follows:
      1. Click the MAPPING > Mapping tab.
      2. Click the Add property to create a new mapping.
      3. Enter the parameters, as follows:

      • Mapping Name: XML_JSON_Mapping
      • Type: XSLT (select from the drop-down list.)
      • New File: Click Choose File and select the XSLT file.
      • Response Type: Full (select from the drop-down list.)
      • Save the changes to your configuration.

    5. Select the mapper for the facade operation, as follows:
      1. Click the ROUTING > Facade Operations tab.
      2. Select the facade operation.
      3. In the Response Transform field, select the XML_JSON_Mapping mapper, as created in the mapping configuration from the drop-down list.
      4. Save the changes to your configuration.