2. An ESB is expected to function as a service provider as well as a
consumer. This tutorial will explain how Mule ESB can be
configured to function as a RESTful WebService endpoint. Mule
ESB provides a built-in REST component based on Jersey project.
In the first example, we will explore the possibility of creating
RESTful web services without using the built-in component;
3. The HTTP endpoint of the flow is configured as below. The
examples of the earlier post covered one way HTTP end point,
this one covers two way or request-response paradigm.
The following configuration settings are done in the ‘General’
tab of the HTTP component.
Exchange-patterns: request-response
Host: localhost
Port: 8081
Path: rest
4. The next component in the flow is Body to Parameter Body.
Retain the default values. The final component in the flow is
Maps to XML component. Retain the default values for this
component as well.
To invoke the application, open any browser window and
type the following:
http://localhost:8081/rest?name=Rori&age=33
The output generated in the browser window is shown below:
6. The source code of the mule flow is shown below:
<?xml version="1.0" encoding="UTF-8"?>
<mule
xmlns:tracking=http://www.mulesoft.org/schema/mule/ee/tra
cking xmlns:jdbc-
ee=http://www.mulesoft.org/schema/mule/ee/jdbc
xmlns:http="http://www.mulesoft.org/schema/mule/http"
9. For all practical purposes, the developer would like to have the
ability to customize the output XML into a more sensible format
aligned to business domain. To achieve the same a new Mule
flow is created.
The grapfhic flow is: