Illustrates how to use Anypoint DataWeave to process an order by looking up information from an external API. It also shows how to expose that external API by using APIkit. As part of the order processing, filters and transformations are applied to the order and a final report is created.
Set Up and Run the Example
Complete the following procedure to create, then run this example in your own instance of Mule Studio. Skip ahead to the next section if you prefer to simply examine this example.
- Open the Example project in Anypoint Studio from Anypoint Exchange. Do not run the application.
- In the Package Explorer, under the
src/main/resourcesfolder create two new folders named input and output. Now, run the example as a Mule Application.
- This project includes a sample XML file, called orders.xml, that you can use to witness end-to-end functionality of the application. In the Package Explorer, click the
src/main/resourcesfolder to expand it, then find the orders.xml file inside this folder.
- Click and drag the orders.xml file into the input folder in the same directory.
- The File Endpoint in the application polls the input folder every ten seconds. It picks up the XML file, processes it, then deposits the JSON output and a CSV report into the output folder in the same directory. (Hit F5 to refresh the contents of the input and output folders.)
- The Message Enricher consumes the API exposed in the currency.xml configuration file and saves the response in the currencies flow variable.
- The API consumed is exposed in currency.xml configuration file by using APIkit and a Parse Template component to build the response.