Changing the default message format

Last modified by Danniar Firdausy on 2024/09/18 13:34

In our crash course on the API Gateway pattern, we explored how to set up an API Gateway with JSON as the default message format. However, there are situations where other formats, like XML, may be more suitable. This microlearning will guide you through changing the default message format and explain how this adjustment impacts the flow creation process in Create.

Should you have any questions, please contact academy@emagiz.com.

1. Prerequisites

  • Basic knowledge of the eMagiz platform

2. Key concepts

There are no specific concepts to consider for now that require additional explanation.

3. Changing the default messaging format

In our crash course on the API Gateway pattern, we have learned about setting up the API Gateway. By default, the messaging format selected for your gateway is JSON. However, the default messaging format can be changed in your project to for example, XML. This change can be made in Design -> Settings -> API Management. On the right side of this overview are the gateway settings. The last entry of this overview is the Default Format. By clicking on the Edit settings button, you enter the following overview

intermediate-api-management-changing-default-messaging-format--edit-settings.png

The last option allows you to switch between JSON or XML as your default messaging format in the gateway. In order to apply your new default to your project, you must press "Apply settings" in Design -> Architecture to confirm your change*.

Information

* Note Changing the default messaging format does not affect existing operations in Create. Migrating these flows requires a reset of the exit flow. Additionally, the default response in Catalog has to be changed to application/xml. 

3.1 Impact in Create

After the flows are resetted in Create, the automatic flow creation in the Create phase is adapted to the new default setting. When changing the messaging format to XML, the components of newly generated flows are created with different names and settings. The image below shows an example of an API GET operation with XML as the default messaging format. Besides the changed naming of the transformation, no JSON factory support objects are required in your flow in comparison with a JSON messaging format.

intermediate-api-management-changing-default-messaging-format--get-operation.png

4. Key takeaways

  • The default messaging format for your API Gateway can be changed, such as from JSON to XML, in the gateway settings.
  • This change only affects newly created flows; existing flows remain unchanged unless manually updated.
  • To migrate existing flows to the new default format, reset the exit flow and update the default response format in Catalog.
  • Changing the default format simplifies flow creation by adjusting component names and settings to match the selected format (e.g., XML).

5. Suggested Additional Readings

If you are interested in this topic and want more information, please read the help text provided by eMagiz and see the following link: