Aggregate API Invocation
home
Illustrates how to aggregate responses from multiple APIs into a single response. It is complementary to the developer blog series that gives step by step instructions to build out this example.
Assumptions
This document describes the details of the example within the context of Anypoint™ Studio, Mule ESB’s graphical user interface (GUI). Where appropriate, the XML configuration accompanies the Studio interface screenshots. This document assumes that you are familiar with Mule ESB, the Anypoint Studio interface.
Example
In this use case we receive a customerId query parameter as an input. We will use this value to invoke two APIs. One to fetch customer details and the other to fetch account details.These APIs can be REST service or SOAP based web services. Once the APIs are invoked the response from both are aggregated and mapped to the final response message.
We will use scatter gather design pattern to invoke multiple APIs in parallel. Once all the responses are collected, we finally map it to the output.
Set Up and Run the Example
In this example we invoke two APIs, Customer REST API and Expose a Database through a SOAP Web Service. We have covered in out previous blog posts on how to create these services. Check out the links, HowTo – Build a REST API with XML payload and HowTo – Wrap SOAP web service around a database
To run this example, download the Mule project from Exchange and deploy it to Mule iPass.
After running the services open the Example project in Anypoint Studio from Anypoint Exchange.
Open src/main/app/mule-app.properties and add the properties for the two services.
Run the example application in Anypoint Studio or Standalone
If you are running the project in Anypoint Studio then test it using the APIkit Console that pops up after running the project. If you are following the sample projects then try customerid = 1.