Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to implement a dummy REST API in WSO2 ESB

I have been trying to implement a simple heart beat REST API in WSO2 ESB and am not able to get a response back. Below is the API

<api xmlns="http://ws.apache.org/ns/synapse" name="HealthCheckAPI" context="/HealthCheck">
   <resource methods="GET" url-mapping="/status" faultSequence="fault">
      <inSequence>
         <payloadFactory media-type="json">
            <format>{"Status":"OK"}</format>
            <args></args>
         </payloadFactory>
         <log>
            <property name="JSON-Payload" expression="json-eval($.)"></property>
         </log>
         <property name="messageType" value="application/json" scope="axis2" type="STRING"></property>
         <respond></respond>
      </inSequence>
   </resource>
</api>

When I curl the API, the response is zero length. What could be wrong?

curl -v http://localhost:8280/HealthCheck/status

like image 775
Shibu Avatar asked Feb 17 '15 22:02

Shibu


1 Answers

You need to set following property .

<property name="NO_ENTITY_BODY" scope="axis2" action="remove"></property>

Please find the working example

<api xmlns="http://ws.apache.org/ns/synapse" name="HealthCheckAPI" context="/HealthCheck">
   <resource methods="GET" url-mapping="/status" faultSequence="fault">
      <inSequence>

         <payloadFactory media-type="json">
            <format>{"Status":"OK"}</format>
            <args></args>
         </payloadFactory>
         <log>
            <property name="JSON-Payload" expression="json-eval($.)"></property>
         </log>

         <property name="NO_ENTITY_BODY" scope="axis2" action="remove"></property>
         <property name="messageType" value="application/json" scope="axis2" type="STRING"></property>
         <respond></respond>
      </inSequence>
   </resource>
</api>
like image 149
Jenananthan Avatar answered Nov 14 '22 10:11

Jenananthan