I am working on a WSO2 Integration Studio project where I need to call an external API that returns an HTML response. I want to save this response into a property so I can use it later in the flow (e.g., logging or processing).
Here is the relevant part of my configuration:
<resource methods="GET" uri-template="/currentsession">
<inSequence>
<call>
<endpoint>
<http method="get" uri-template="http://example.com/api">
<suspendOnFailure>
<initialDuration>-1</initialDuration>
<progressionFactor>-1</progressionFactor>
<maximumDuration>0</maximumDuration>
</suspendOnFailure>
<markForSuspension>
<retriesBeforeSuspension>0</retriesBeforeSuspension>
</markForSuspension>
<authentication>
<basicAuth>
<username>test</username>
<password>test</password>
</basicAuth>
</authentication>
</http>
</endpoint>
</call>
<!-- Attempt to save response -->
<property name="response" scope="default" type="STRING" expression="$ctx:ORIGINAL_MESSAGE"/>
<!-- Logging the saved property -->
<log>
<property expression="get-property('response')" name="tt"/>
</log>
<respond/>
</inSequence>
<outSequence/>
<faultSequence/>
</resource>
However, this setup does not store the actual HTML response in the response property as expected. The log shows it as empty or null.
$ctx:ORIGINAL_MESSAGE
$ctx:messageBody
$ctx:axis2_message_body
$body
<property>
mediator to various locations within the <inSequence>
to check if response context changes after <call>
.Content-Type: text/html
) and correctly returns content when accessed manually.<call>
mediator and save it in a property?$ctx:ORIGINAL_MESSAGE
the correct expression for this use case? If not, what should I use?Did you mean to do the below? I don't see you have assigned a value to ORIGINAL_MESSAGE
.
<property name="response" scope="default" type="STRING" expression="$body"/>
<log>
<property expression="get-property('response')" name="tt"/>
</log>
Update
Add the following to the deployment.toml
. Make sure the content_type
is the same as the Content-Type header that comes in the response.
[[custom_message_builders]]
class = "org.apache.axis2.format.PlainTextBuilder"
content_type = "text/html"