0
votes

I am using WSO2 Integrator 6.6.0 to make a blocking HTTP GET to a REST API that returns a JSON response (HTTP 200 OK).

But I never see the response body inside my sequences. I am not sure what I am doing wrong, having exhausted all available documentation and other threads.

Sequence doing the call (simplified to anonymize), which logs the response afterwards:

<!-- Remove XML body as not needed for GET request -->
<payloadFactory media-type="json">
    <format></format>
    <args></args>
</payloadFactory>
<header name="Accept" value="application/json" scope="transport"/>
<property name="NO_ENTITY_BODY" value="true" scope="axis2" type="BOOLEAN" />

<call blocking="true">
    <endpoint>
         <http method="GET" uri-template="http://my-api/order-status">
    </endpoint>
</call>
<property name="RESPONSE" scope="default" type="STRING" value="true"/>
<log level="full">
    <property name="response-log" value="Received response"/>
    <property expression="$body" name="response-body"/>
    <property expression="json-eval($)" name="json-eval-body"/>
</log>

This results simply into a log line - with no response body at all!

INFO {org.apache.synapse.mediators.builtin.LogMediator} - To: http://my-api/order-status, WSAction: urn:mediate, SOAPAction: urn:mediate, MessageID: ID:414d51204343494153303131202020209ca4175f28ac422e, Direction: response, response-log = Received response, response-body = <soapenv:Body xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"></soapenv:Body>, json-eval-body = {}, Payload: {}

I can see the request in my API application and I can also see what it correctly returns a response body in its logs. Also, using Postman to do the same request I receive the following JSON response with 200 OK and Content-Type appication/json:

{
   "order_status": "NOT_FOUND"
}

Inside WSO2 I do not see anything! I want to be able to convert the response into XML format.

What could be wrong?

3

3 Answers

0
votes

Before making a REST call, it is necessary to remove the headers from the main call.

Put this snippet before the call mediator:

<property name = "FORCE_HTTP_CONTENT_LENGTH" scope = "axis2" type = "STRING" value = "true" />
     <property action = "remove" name = "REST_URL_POSTFIX" scope = "axis2" />
     <property action = "remove" name = "TRANSPORT_HEADERS" scope = "axis2" />

As I understand it should solve.

0
votes

Can you modify the NO_ENTITY_BODY property as follows and try this mediation again.

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

Having simplified this configuration for this question, I had missed that having the following property set in my proxy service:

<property name="OUT_ONLY" scope="default" type="STRING" value="true"/>

Means that WSO2 is ignoring the response from the API. Removing this property resolved the issue for the following config:

<header name="Accept" value="application/json" scope="transport" />
<property action="remove" name="NO_ENTITY_BODY" scope="axis2"/>
<property name="messageType" scope="axis2" type="STRING" value="application/json"/>
<call blocking="true">
    <endpoint key="conf:/endpoints/FX_TRADING_API_ORDERSTATUS.xml"/>
</call>