Hi Isuru, We are already tracking this requirement in [1] and will be adding this to APIM 2.2.0.
[1] https://wso2.org/jira/browse/APIMANAGER-5529 On Tue, Jan 16, 2018 at 12:45 PM, Isuru Haththotuwa <[email protected]> wrote: > Previously there were a few issues with using JsonStreamBuilder and > JsonStreamFormatter in APIM, hence by default APIM used JsonBuilder and > JsonFormatter (up to the release 2.1.0). I think we can move to > JsonStreamBuilder and JsonStreamFormatter in the 2.2.0 release. > > On Tue, Jan 9, 2018 at 8:59 PM, Sameera Gunarathne <[email protected]> > wrote: > >> Hi Milinda, >> >> I have tried the suggestion and that way I can access the message >> payload. I can see in the axis2.xml in apim 2.2.0 this configuration is >> commented and uses JsonBuilder instead. >> >> <!--JSON Message Builders--> >> <messageBuilder contentType="application/json" >> class="org.apache.synapse.comm >> ons.json.JsonBuilder"/> >> <!--messageBuilder contentType="application/json" >> class="org.apache.synapse.comm >> ons.json.JsonStreamBuilder"/--> >> >> Is there any specific reason to use JsonBuilder and what would be the >> impact of using JsonStreamBuilder? >> >> Thanks and Regards, >> >> On Tue, Jan 9, 2018 at 8:49 PM, Milinda Perera <[email protected]> wrote: >> >>> Hi Sameera, >>> >>> Please add JsonStreamBuilder instead of JsonBuilder and try >>> >>> <messageBuilder contentType="application/json" >>> class="org.wso2.carbon.integra >>> tor.core.json.JsonStreamBuilder"/> >>> >>> Thanks, >>> Milinda >>> >>> On Tue, Jan 9, 2018 at 8:44 PM, Sameera Gunarathne <[email protected]> >>> wrote: >>> >>>> Hi, >>>> >>>> I'm using a script mediator to get JSON payload inside an API sequence. >>>> I'm using a payload as follows. >>>> >>>> curl -X POST --header 'Content-Type: application/json' --header 'Accept: >>>> application/xml' --header 'Authorization: Bearer >>>> c4f97c6e-60fc-3c26-97ad-48b9c9fa4566' -d '{ \ >>>> "PhoneNumbers": ["123456789"] \ >>>> }' 'https://10.100.7.133:8243/phoneVerify/1.0.0/checkPhoneNumbers >>>> >>>> I'm accessing the payload inside the script mediator as follows. >>>> >>>> <script language="js"> >>>> var payload = mc.getPayloadJSON(); >>>> </script> >>>> >>>> There I get following exception at the script mediator on the >>>> json payload being null. >>>> >>>> [2018-01-09 20:37:55,454] ERROR - ScriptMessageContext JSON object is >>>> null. >>>> [2018-01-09 20:37:55,458] ERROR - ScriptMediator The script engine >>>> returned an error executing the inlined js script function mediate >>>> >>>> but I have looked into the wirelogs and the json message comes to the >>>> sequence. >>>> >>>> [2018-01-09 20:37:55,445] DEBUG - wire HTTPS-Listener I/O dispatcher-6 >>>> >> "Accept-Language: en-US,en;q=0.9,nl;q=0.8[\r][\n]" >>>> [2018-01-09 20:37:55,445] DEBUG - wire HTTPS-Listener I/O dispatcher-6 >>>> >> "[\r][\n]" >>>> [2018-01-09 20:37:55,445] DEBUG - wire HTTPS-Listener I/O dispatcher-6 >>>> >> "{[\n]" >>>> [2018-01-09 20:37:55,445] DEBUG - wire HTTPS-Listener I/O dispatcher-6 >>>> >> " *"PhoneNumbers": ["123456789"][\n]"* >>>> [2018-01-09 20:37:55,445] DEBUG - wire HTTPS-Listener I/O dispatcher-6 >>>> >> "}" >>>> >>>> What could be the reason for this? Any other suggestions to access >>>> message context inside a script mediator. >>>> >>>> Thanks and Regards, >>>> Sameera. >>>> -- >>>> Sameera Gunarathne >>>> Software Engineer, WSO2 Inc. http://wso2.com >>>> <http://l.facebook.com/l.php?u=http%3A%2F%2Fwso2.com&h=gAQEswASa> >>>> Email: [email protected] >>>> Mobile: +94714155561 >>>> >>> >>> >>> >>> -- >>> Milinda Perera >>> Senior Software Engineer; >>> WSO2 Inc. http://wso2.com , >>> Mobile: (+94) 714 115 032 <+94%2071%20411%205032> >>> >>> >> >> >> -- >> Sameera Gunarathne >> Software Engineer, WSO2 Inc. http://wso2.com >> <http://l.facebook.com/l.php?u=http%3A%2F%2Fwso2.com&h=gAQEswASa> >> Email: [email protected] >> Mobile: +94714155561 >> >> _______________________________________________ >> Dev mailing list >> [email protected] >> http://wso2.org/cgi-bin/mailman/listinfo/dev >> >> > > > -- > Thanks and Regards, > > Isuru H. > +94 716 358 048 <+94%2071%20635%208048>* <http://wso2.com/>* > > > -- Thilini Shanika Senior Software Engineer WSO2, Inc.; http://wso2.com 20, Palmgrove Avenue, Colombo 3 E-mail: [email protected]
_______________________________________________ Dev mailing list [email protected] http://wso2.org/cgi-bin/mailman/listinfo/dev
