Hi,
My understanding is your requirement is to achieve {"tags":["TestTag"]}
you can easily done this with following. Combining payload mediator and
script mediator.
<payloadFactory media-type="xml">
<format>
<jsonObject xmlns=""><?xml-multiple?></jsonObject>
</format>
<args/>
</payloadFactory>
<script language="js">payloadXML = mc.getPayloadXML();
payloadXML.jsonObject +=
<?xml-multiple?><tags><jsonElement>TestTag</jsonElement></tags&gt;
print(payloadXML);
mc.setPayloadXML(payloadXML);</script>
Moreover this can also be done using given samples in [1]
[1] https://docs.wso2.com/display/ESB481/JSON+Support
Best Regards,
Malaka
On Tue, Aug 12, 2014 at 4:11 PM, Malaka Silva <[email protected]> wrote:
> Hi,
>
> There is not script mediator used in the configuration you sent.
>
> Following is the output for that.
>
> [2014-08-12 16:08:12,390] DEBUG - wire >> "POST
> /services/pass1.pass1HttpSoap12Endpoint HTTP/1.1[\r][\n]"
> [2014-08-12 16:08:12,390] DEBUG - wire >> "Content-Type:
> application/soap+xml; charset=UTF-8; action="urn:mediate"[\r][\n]"
> [2014-08-12 16:08:12,391] DEBUG - wire >> "Cookie:
> region3_registry_menu=visible; menuPanel=visible; menuPanelType=main;
> region1_configure_menu=none; region4_monitor_menu=none;
> region5_tools_menu=none;
> requestedURI="../../carbon/service-mgt/index.jsp?region=region1&item=services_list_menu";
> JSESSIONID=A652FAE3D43E1ACEF72AB6060609AA68;
> current-breadcrumb=manage_menu%2Cservices_menu%2Cservices_list_menu%23;
> MSG14078183094500.4606495099950271=true;
> MSG14078183198250.2019032806534964=true;
> MSG14078183337640.8369394687123034=true;
> MSG14078185781460.4222625543797929=true;
> MSG14078186327360.3619132076277993=true;
> MSG14078186445170.8474369217867975=true;
> MSG14078189363290.09887523460529613=true;
> MSG14078202820720.3139562562501682=true;
> MSG14078213631700.20356205159007335=true;
> MSG14078380807410.0045559539948989425=true[\r][\n]"
> [2014-08-12 16:08:12,391] DEBUG - wire >> "User-Agent: Axis2[\r][\n]"
> [2014-08-12 16:08:12,391] DEBUG - wire >> "Host: 10.100.0.29:8280[\r][\n]"
> [2014-08-12 16:08:12,391] DEBUG - wire >> "Transfer-Encoding:
> chunked[\r][\n]"
> [2014-08-12 16:08:12,391] DEBUG - wire >> "[\r][\n]"
> [2014-08-12 16:08:12,391] DEBUG - wire >> "a0[\r][\n]"
> [2014-08-12 16:08:12,392] DEBUG - wire >> "<?xml version="1.0"
> encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="
> http://www.w3.org/2003/05/soap-envelope
> "><soapenv:Body></soapenv:Body></soapenv:Envelope>[\r][\n]"
> [2014-08-12 16:08:12,392] DEBUG - wire >> "0[\r][\n]"
> [2014-08-12 16:08:12,392] DEBUG - wire >> "[\r][\n]"
> [2014-08-12 16:08:12,396] INFO - LogMediator To:
> /services/pass1.pass1HttpSoap12Endpoint, WSAction: urn:mediate, SOAPAction:
> urn:mediate, MessageID: urn:uuid:52c1fe22-4f6f-4539-a39f-4eedd9d13ae3,
> Direction: request, Envelope: <?xml version="1.0"
> encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="
> http://www.w3.org/2003/05/soap-envelope"><soapenv:Body><jsonObject><?xml-multiple
>
> ?><tags><jsonElement>TestTag</jsonElement></tags><name>Janaka</name></jsonObject></soapenv:Body></soapenv:Envelope>
> [2014-08-12 16:08:12,399] INFO - LogMediator To:
> /services/pass1.pass1HttpSoap12Endpoint, WSAction: urn:mediate, SOAPAction:
> urn:mediate, MessageID: urn:uuid:52c1fe22-4f6f-4539-a39f-4eedd9d13ae3,
> Direction: request, Janaka = {"tags":["TestTag"],"name":"Janaka"}
> [2014-08-12 16:08:12,403] DEBUG - wire << "POST /service/echo
> HTTP/1.1[\r][\n]"
> [2014-08-12 16:08:12,404] DEBUG - wire << "Content-Type: application/json;
> charset=UTF-8[\r][\n]"
> [2014-08-12 16:08:12,404] DEBUG - wire << "Cookie:
> region3_registry_menu=visible; menuPanel=visible; menuPanelType=main;
> region1_configure_menu=none; region4_monitor_menu=none;
> region5_tools_menu=none;
> requestedURI="../../carbon/service-mgt/index.jsp?region=region1&item=services_list_menu";
> JSESSIONID=A652FAE3D43E1ACEF72AB6060609AA68;
> current-breadcrumb=manage_menu%2Cservices_menu%2Cservices_list_menu%23;
> MSG14078183094500.4606495099950271=true;
> MSG14078183198250.2019032806534964=true;
> MSG14078183337640.8369394687123034=true;
> MSG14078185781460.4222625543797929=true;
> MSG14078186327360.3619132076277993=true;
> MSG14078186445170.8474369217867975=true;
> MSG14078189363290.09887523460529613=true;
> MSG14078202820720.3139562562501682=true;
> MSG14078213631700.20356205159007335=true;
> MSG14078380807410.0045559539948989425=true[\r][\n]"
> [2014-08-12 16:08:12,405] DEBUG - wire << "Transfer-Encoding:
> chunked[\r][\n]"
> [2014-08-12 16:08:12,405] DEBUG - wire << "Host: localhost:9000[\r][\n]"
> [2014-08-12 16:08:12,405] DEBUG - wire << "Connection: Keep-Alive[\r][\n]"
> [2014-08-12 16:08:12,405] DEBUG - wire << "User-Agent:
> Synapse-HttpComponents-NIO[\r][\n]"
> [2014-08-12 16:08:12,405] DEBUG - wire << "[\r][\n]"
> [2014-08-12 16:08:12,407] DEBUG - wire << "24[\r][\n]"
> [2014-08-12 16:08:12,407] DEBUG - wire <<
> "{"tags":["TestTag"],"name":"Janaka"}[\r][\n]"
> [2014-08-12 16:08:12,407] DEBUG - wire << "0[\r][\n]"
> [2014-08-12 16:08:12,408] DEBUG - wire << "[\r][\n]"
> [2014-08-12 16:08:12,408] DEBUG - wire >> "HTTP/1.1 200 OK[\r][\n]"
> [2014-08-12 16:08:12,408] DEBUG - wire >> "Server:
> Apache-Coyote/1.1[\r][\n]"
> [2014-08-12 16:08:12,408] DEBUG - wire >> "port: 9000[\r][\n]"
> [2014-08-12 16:08:12,409] DEBUG - wire >> "Content-Type:
> application/json;charset=UTF-8[\r][\n]"
> [2014-08-12 16:08:12,409] DEBUG - wire >> "Content-Length: 36[\r][\n]"
> [2014-08-12 16:08:12,409] DEBUG - wire >> "Date: Tue, 12 Aug 2014 10:38:12
> GMT[\r][\n]"
> [2014-08-12 16:08:12,409] DEBUG - wire >> "[\r][\n]"
> [2014-08-12 16:08:12,410] DEBUG - wire >>
> "{"tags":["TestTag"],"name":"Janaka"}"
> [2014-08-12 16:08:12,414] DEBUG - wire << "HTTP/1.1 200 OK[\r][\n]"
> [2014-08-12 16:08:12,416] DEBUG - wire << "Content-Type: application/json;
> charset=UTF-8[\r][\n]"
> [2014-08-12 16:08:12,416] DEBUG - wire << "port: 9000[\r][\n]"
> [2014-08-12 16:08:12,416] DEBUG - wire << "Server:
> Apache-Coyote/1.1[\r][\n]"
> [2014-08-12 16:08:12,417] DEBUG - wire << "Date: Tue, 12 Aug 2014 10:38:12
> GMT[\r][\n]"
> [2014-08-12 16:08:12,417] DEBUG - wire << "Transfer-Encoding:
> chunked[\r][\n]"
> [2014-08-12 16:08:12,417] DEBUG - wire << "[\r][\n]"
> [2014-08-12 16:08:12,418] DEBUG - wire << "22[\r][\n]"
> [2014-08-12 16:08:12,418] DEBUG - wire <<
> "{"tags":"TestTag","name":"Janaka"}[\r][\n]"
> [2014-08-12 16:08:12,418] DEBUG - wire << "0[\r][\n]"
> [2014-08-12 16:08:12,418] DEBUG - wire << "[\r][\n]"
>
>
>
> On Tue, Aug 12, 2014 at 3:52 PM, Jay <[email protected]>
> wrote:
>
>> Hi Malaka,
>>
>> Following is my configuration with inline script mediator:
>>
>>
>> <template name="createOpportunity" xmlns="http://ws.apache.org/ns/synapse
>> ">
>> <sequence>
>> <payloadFactory media-type="xml">
>> <format>
>> <jsonObject xmlns=""><?xml-multiple?>
>> <tags>
>> <jsonElement>TestTag</jsonElement>
>> </tags>
>> <name>Janaka</name>
>> </jsonObject>
>>
>> </format>
>> <args />
>> </payloadFactory>
>>
>> **
>>
>> <property name="messageType" value="application/json"
>> scope="axis2"
>> type="STRING" />
>> <log level="full"/>
>>
>> <log>
>> <property name="Janaka"
>> expression="json-eval($.)" />
>> </log>
>> <call>
>> <endpoint>
>> <http method="post"
>> uri-template="{uri.var.apiUrl}/opportunity" />
>> </endpoint>
>> </call>
>>
>> </sequence>
>> </template>
>>
>>
>>
>>
>>
>>
>>
>> --
>> View this message in context:
>> http://wso2-oxygen-tank.10903.n7.nabble.com/ESB-Problems-sending-numeric-keys-in-JSON-Payloads-tp99789p101262.html
>> Sent from the WSO2 Development mailing list archive at Nabble.com.
>> _______________________________________________
>> Dev mailing list
>> [email protected]
>> http://wso2.org/cgi-bin/mailman/listinfo/dev
>>
>
>
>
> --
>
> Best Regards,
>
> Malaka Silva
> Senior Tech Lead
> M: +94 777 219 791
> Tel : 94 11 214 5345
> Fax :94 11 2145300
> Skype : malaka.sampath.silva
> LinkedIn : http://www.linkedin.com/pub/malaka-silva/6/33/77
> Blog : http://mrmalakasilva.blogspot.com/
>
> WSO2, Inc.
> lean . enterprise . middleware
> http://www.wso2.com/
> http://www.wso2.com/about/team/malaka-silva/
> <http://wso2.com/about/team/malaka-silva/>
>
> Save a tree -Conserve nature & Save the world for your future. Print this
> email only if it is absolutely necessary.
>
--
Best Regards,
Malaka Silva
Senior Tech Lead
M: +94 777 219 791
Tel : 94 11 214 5345
Fax :94 11 2145300
Skype : malaka.sampath.silva
LinkedIn : http://www.linkedin.com/pub/malaka-silva/6/33/77
Blog : http://mrmalakasilva.blogspot.com/
WSO2, Inc.
lean . enterprise . middleware
http://www.wso2.com/
http://www.wso2.com/about/team/malaka-silva/
<http://wso2.com/about/team/malaka-silva/>
Save a tree -Conserve nature & Save the world for your future. Print this
email only if it is absolutely necessary.
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev