MuleSoft: REST web Service Development

Learn about how to expose and consume simple RESTful web service in Mule Anypoint.


Steps required to execute:

  1. Configure Http endpoint in Anypoint studio
  2. Create Java implementation for service
  3. Configure the REST component
  4. Test the Rest Service

Configure Http endpoint in Anypoint studio:

create a Flow with Http endpoint, configure the HTTP endpoint with Host and port as localhost and 8081.


create a package under source folder src/main/java



Create Java implementation for service



public class SimpleRestTest {

public Response getWishes(@PathParam(“name”)String name){
String output = “Hi ” + name;
return Response.status(200).entity(output).build();


Configure the REST component

Drag and drop REST component from component pallette, and  configure the developed Java implementation as Spring bean.



Click ok, Finish and Finish.

Configuration is complete and ready to deploy the flow file as below

<?xml version=”1.0″ encoding=”UTF-8″?>

<mule xmlns:jersey=”; xmlns:http=”; xmlns=”; xmlns:doc=”;
<http:listener-config name=”HTTP_Listener_Configuration” host=”localhost” port=”8081″ doc:name=”HTTP Listener Configuration”/>
<spring:bean id=”Bean” name=”Bean” class=”” scope=”singleton”/>
<spring:bean id=”simpleRest” name=”simpleRest” class=””/>
<flow name=”restdemoFlow”>
<http:listener config-ref=”HTTP_Listener_Configuration” path=”/*” doc:name=”HTTP”/>
<jersey:resources doc:name=”REST”>
<spring-object bean=”Bean”/>

Test the Rest Service:

Deploy the Flow to Mule runtime from AnyPoint studio, Make sure the flow deployed properly

Open browser and hit the Url:  http://localhost:8081/users/sai

You can watch Response as Hi Sai in the browser:

Congragulations ! you configured simple Rest service in Mule Flow.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s