Hi Rajith/Raj, Thanks for the responses. Both methods worked for me, and yes you need to build the message first.
On Thu, Oct 27, 2016 at 7:16 PM, Rajkumar Rajaratnam <[email protected]> wrote: > > > On Thu, Oct 27, 2016 at 9:42 AM, Rajkumar Rajaratnam <[email protected]> > wrote: > >> 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); >> > > This code worked for me in AM 1.10. > > >> >> >> Also make sure you are using org.apache.synapse.commo >> ns.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.g >>> etEnvelope().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 >> > > > > -- > Rajkumar Rajaratnam > Committer & PMC Member, Apache Stratos > Senior Software Engineer, WSO2 > > Mobile : +94777568639 > -- 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
