Hi Isuru,
I think you have to build the message first and call jsonPayloadToString().
Try this.
try {
RelayUtils.buildMessage(a2mc);
} catch (IOException | XMLStreamException e) {
log.error("Error occurred while building the message", e);
}
JsonUtil.jsonPayloadToString(a2mc);
Also make sure you are using
org.apache.synapse.commons.json.JsonStreamFormatter/org.apache.synapse.commons.json.JsonStreamBuilder
for application/json.
Thanks,
Raj.
On Thu, Oct 27, 2016 at 9:28 AM, Rajith Vitharana <[email protected]> wrote:
> Hi Isuru,
>
> Below [1] worked for me to retrieve jsonbody. And then to set it back,
> what you did worked for me. IE [2]
>
> [1] - StringBuilder json = JsonUtil.toJsonString(synCtx.
> getEnvelope().getBody());
> [2] - JsonUtil.getNewJsonPayload(
> ((Axis2MessageContext) synCtx).
> getAxis2MessageContext(),
> transformedJson, true, true);
>
> Thanks,
>
> On 27 October 2016 at 17:55, Isuru Haththotuwa <[email protected]> wrote:
>
>> Hi,
>>
>> How to do $subject? Need to modify the response payload from BE and send
>> it to the client.
>>
>> Tried [1], but did not work.
>>
>> [1].
>> String jsonPayloadToString = JsonUtil
>> .jsonPayloadToString(((Axis2MessageContext)
>> messageContext)
>> .getAxis2MessageContext());
>> try {
>> JsonUtil.getNewJsonPayload(((Axis2MessageContext)
>> messageContext).getAxis2MessageContext(),
>> jsonPayloadToString, true, true);
>> } catch (AxisFault axisFault) {
>> log.error("Error building aggregated JSON payload",
>> axisFault);
>> return false;
>> }
>>
>> --
>> Thanks and Regards,
>>
>> Isuru H.
>> +94 716 358 048* <http://wso2.com/>*
>>
>>
>>
>> _______________________________________________
>> Dev mailing list
>> [email protected]
>> http://wso2.org/cgi-bin/mailman/listinfo/dev
>>
>>
>
>
> --
> Rajith Vitharana
>
> Senior Software Engineer,
> WSO2 Inc. : wso2.com
> Mobile : +94715883223
> Blog : http://lankavitharana.blogspot.com/
> <http://wso2.com/signature>
>
> _______________________________________________
> Dev mailing list
> [email protected]
> http://wso2.org/cgi-bin/mailman/listinfo/dev
>
>
--
Rajkumar Rajaratnam
Committer & PMC Member, Apache Stratos
Senior Software Engineer, WSO2
Mobile : +94777568639
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev