Illustrates how to define a REST API that accepts XML payload as the input. It is complementary to the developer blog article that gives step by step instructions to build this example.
This document describes the details of the example within the context of Anypoint Studio. Where appropriate, the XML configuration accompanies the Studio interface
screenshots. This document assumes that you are familiar with Mule and the Anypoint Studio interface.
In this example we have a XML request that contains customer ID. We need to look up customer details from a database table for incoming customer id and send back the XML response.
Set Up and Run the Example
As with other examples, you can create template applications straight out of the box in Anypoint Studio. You can tweak the configurations of these use case-based examples to create your own customized applications in Mule.
Follow the procedure below to create, then run the REST XML payload How To example.
- Query a database table. To use this example project as is, create a table "customer" using this SQL example
- After you create the table, configure the database connector with the details and the driver for the database you are using. Configure the details in file mule-app.properties
- To test the project use this sample input request in the API console. Change the customer ID in the input request as per the sample data in your database table.
- If using a different database table make sure to update the select statement in the database connector. Currently it is configured to query "customer" table by fetching the customer ID from the incoming request message.
To learn how to build this example out check out this blog where we give step by step instructions.