Using WSO2 ESB HTTP Endpoints to define Restful Endpoints

When we consider about the endpoints which has been allowed in WSO2 ESB there are several as follows

  • Address Endpoint
  • Dynamic Load-balance Endpoint
  • Failover Group
  • HTTP Endpoint
  • WSDL Endpoint
  • Load-balance Group
  • Indirect and Resolving Endpoints
  • Default Endpoint
  • Template Endpoint
  • Recipient List Endpoint

In this post I am going to take you through, how to use HTTP Endpoints to define Restful Endpoints. You can use Uri Templates to achieve this. There we can use the variables to retrieve the values of the uri at run time.

In order to demonstrate this I am going to define an api which I am going to access through an HTTP Endpoint and a proxy service.

<endpoint xmlns="" name="TestHttpEP">
   <http uri-template="http://localhost:8280/tutorial/{uri.var.param}/{uri.var.val}" method="get">

In the above defined HTTP Endpoint, uri-template attribute has been set to the resource defined in the bellow API. Also You can see the variables inside the curly Braces. These variables get the defined property values at the run time and generate the required uri. These properties have been defined in the proxy service's in sequence in which I am invoking.

<proxy xmlns=""
         <property name="uri.var.param" value="parameter" scope="default" type="STRING"/>
         <property name="uri.var.val" value="1234" scope="default" type="STRING"/>
         <property name="NO_KEEPALIVE" value="true" scope="axis2"/>
            <property name="In_Seq" value="Hit In Sequence"/>
            <endpoint key="TestHttpEP"/>
            <property name="Out_Seq" value="Hit Out Sequence"/>

<api xmlns="" name="testApi" context="/tutorial">
   <resource methods="GET" uri-template="/test/val" faultSequence="fault">
            <property name="IN_SEQ_LOG" value="HIT_IN_SEQ"/>
         <payloadFactory media-type="xml">
               <test xmlns="">TEST</test>
            <property name="OUT_SEQ_LOG" value="OUT_SEQ_HIT"/>

Now invoke the proxy service through any rest client and you will see the response sent through the API as follows.
<test xmlns="">TEST</test>


Popular posts from this blog

Enabling Custom SSL Profiles in WSO2 ESB 4.8.1

Integrating WSO2 ESB Connectors in real world integration Scenarios