Friday, September 14, 2012

REST support in WSO2ESB - Introduction

Version 4.0.3/later versions have an effective REST API mechanism to support REST invocations. The HTTP verbs such as GET/POST/PUT/DELETE..  can be handled with a simple configuration .

Sample REST API configuration to handle a GET request;
 <api name="echoAPI" context="/echo">
      <resource methods="GET"
If you notice that ,here we define the context as "echo" which would be appear in the http url. User has to define a meaningful context if he wants to allow others  to use this API.
The url of the above API would be;
In this API we restricted ESB to handle only the GET requests. So, if user sends  requests for other verbs, those will be dropped at ESB end.

For the ur-template, we get only single parameter from the enduser.
So, to invoke this API, user has to send a single query parameter.

If user sends multiple query parameters he has to define something like;

But it totally depends on the service implementation, how user going to handle the template.

If we have number of query parameters we could simply define the url-mapping like;


This will accept all the GET requests coming with the following URL format;

Related post ;
REST Support in WSO2ESB - Handling JSON messages


  1. Hi Ratha,
    Please describe how to practically test this. I am a beginner for ESB. So I cannot understand where to configure this REST API. Where should I define this REST API in the ESB? How to do it? Please help me.

  2. You should configure in ESB synapse configuration. If you start ESB server, go to management console and you will see API menu where using UI tools you can define an API.