I need help, because I'm already losing faith )) I have a very simple API, which is built on the wso2. Here is my API code :
<?xml version="1.0" encoding="UTF-8"?>
<api context="/dwh" name="dwhCallEp" xmlns="http://ws.apache.org/ns/synapse">
<resource methods="GET" uri-template="/ep/{sysparam}">
<inSequence>
<log level="custom">
<property name="START" value="call into dwh storage"/>
<property expression="get-property('uri.var.sysparam')" name="sysparam"/>
</log>
<call>
<endpoint>
<http method="get" statistics="enable" trace="enable" uri-template="http://my_path?sysparam={uri.var.sysparam}&call_in_async_mode=false">
<timeout>
<duration>120000</duration>
<responseAction>fault</responseAction>
</timeout>
<suspendOnFailure>
<initialDuration>-1</initialDuration>
<progressionFactor>1.0</progressionFactor>
</suspendOnFailure>
<markForSuspension>
<retriesBeforeSuspension>0</retriesBeforeSuspension>
</markForSuspension>
</http>
</endpoint>
</call>
<property expression="json-eval($[0])" name="JsonPayload" scope="default" type="STRING"/>
<log level="full" separator="
">
<property expression="$ctx:JsonPayload" name="JsonPayload"/>
</log>
<script language="js"><![CDATA[var payload = mc.getPayloadJSON();
var log = mc.getServiceLog();
log.info("payload_json : " + payload);
log.info("payload_json : " + JSON.stringify(payload));
mc.setProperty("payload_json",JSON.stringify(payload));]]></script>
<log level="full" separator="
">
<property name="payload" expression="json-eval($)" />
</log>
<respond/>
</inSequence>
<outSequence/>
<faultSequence>
<payloadFactory media-type="xml">
<format>
<error>$1</error>
</format>
<args>
<arg value="something go wrong!!!"/>
</args>
</payloadFactory>
</faultSequence>
</resource>
</api>
I have tried to get the response body in different ways :
- using log level="full" to see everything that was returned by my API after call mediator
- using expression="json-eval($[0])" in property mediator and then write its value to the log
- using script mediator to try to get the payload as mc.getPayloadJSON() and then using JSON.stringify(payload) to get the body string and writing it to a property
- using expression="json-eval($)" in property mediator and then write its value to the log
But none of the methods gave any result.
This is a stack from my logs :
[2024-02-01 11:07:51,198] INFO {LogMediator} - {api:dwhCallEp} START = call into dwh storage, sysparam = pn_citytypes
[2024-02-01 11:07:51,201] INFO {TRACE_LOGGER} - Sending message through endpoint : null resolving to address = http://erp.ukrposhta.loc/ws/api/_MR_DWH_KATALOG?sysparam={uri.var.sysparam}&call_in_async_mode=false
[2024-02-01 11:07:51,201] INFO {TRACE_LOGGER} - SOAPAction: null
[2024-02-01 11:07:51,201] INFO {TRACE_LOGGER} - WSA-Action: null
[2024-02-01 11:07:51,208] INFO {TimeoutHandler} - This engine will expire all callbacks after GLOBAL_TIMEOUT: 120 seconds, irrespective of the timeout action, after the specified or optional timeout
[2024-02-01 11:07:51,254] INFO {LogMediator} - {api:dwhCallEp} To: http://www.w3.org/2005/08/addressing/anonymous
WSAction:
SOAPAction:
MessageID: urn:uuid:d16a7929-5a73-4bd9-9a52-d2431aed680b
correlation_id: 04c91129-739e-4628-a206-ddb3bb047bc1
Direction: request
JsonPayload =
Envelope: <?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body/></soapenv:Envelope>
[2024-02-01 11:07:51,273] INFO {CommonScriptMessageContext} - payload_json : [object Object]
[2024-02-01 11:07:51,274] INFO {CommonScriptMessageContext} - payload_json : {}
[2024-02-01 11:07:51,275] INFO {LogMediator} - {api:dwhCallEp} To: http://www.w3.org/2005/08/addressing/anonymous
WSAction:
SOAPAction:
MessageID: urn:uuid:d16a7929-5a73-4bd9-9a52-d2431aed680b
correlation_id: 04c91129-739e-4628-a206-ddb3bb047bc1
Direction: request
payload =
Envelope: <?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body/></soapenv:Envelope>
Either way, I was getting an empty body as the payload or in the script mediator [object Object].
But Postman returned the payload I should have gotten in my code :
What is wrong ?

I solved this problem by adding the certificate to the keystore of wso2 ei and using the
https://...request in the EP in the CALL mediator instead ofhttp://request. That's why i couldn't write the payload value in the service. Why Postman could do that withhttp://...and get the response, i have no idea ?