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;
The url of the above API would be;
http://localhost:8280/echo
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.
http://localhost:8280/echo?testString
If user sends multiple query parameters he has to define something like;
uri-template="/{string1}/{string2}"
uri-template="/{string1}&{string2}"
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;
url-mapping="/*"
This will accept all the GET requests coming with the following URL format;
http://localhost:8280/echo
Related post ;
REST Support in WSO2ESB - Handling JSON messages
Sample REST API configuration to handle a GET request;
<api name="echoAPI" context="/echo">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.
<resource methods="GET"
uri-template="/{string}"
inSequence="echo-in-seq"
outSequence="echo-out-seq"
faultSequence="fault"/>
</api>
The url of the above API would be;
http://localhost:8280/echo
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.
http://localhost:8280/echo?testString
If user sends multiple query parameters he has to define something like;
uri-template="/{string1}/{string2}"
uri-template="/{string1}&{string2}"
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;
url-mapping="/*"
This will accept all the GET requests coming with the following URL format;
http://localhost:8280/echo
Related post ;
REST Support in WSO2ESB - Handling JSON messages