How to implement dummy REST API in WSO2 ESB

I am trying to implement a simple heart rate REST API in a WSO2 ESB and cannot get a response. 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 twist the API, the answer is zero length. What could be wrong?

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

+5
source share
2 answers

You need to set the following property.

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

Please find a 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> 
+6
source

Shibu, Use the following expression in a media broker. JSON-Eval ($. Status)

0
source

Source: https://habr.com/ru/post/1213572/


All Articles