[Dev] [ESB] Problems sending numeric keys in JSON Payloads

2014-07-21 Thread Jay
Hi,

I am calling an endpoint which requires sending numeric keys in objects in
the following format:
{"1" : "some value"}

However, when processing this using a script mediator, the numeric key is
converted in to a primitive number as follows:
{1 : "some value"}

which is not accepted by the script mediator when setting the payload using
setPayloadJSON. 

This problem can also be seen when sending numeric values (not keys).
Although the values are numeric, the backend does not accept these values if
they are not sent as strings. e.g. {"key":"123"} is converted to {"key":123}
which is not accepted.


I managed to circumvent this problem by processing the payload via XML:

payloadXML = mc.getPayloadXML();
var customFields = 
mc.getProperty("uri.var.customFields");

var jsonObj = 
eval("("+customFields+")");
var customFieldsTag = ;
for(var key in  jsonObj){
var val = jsonObj[key];
customFieldsTag.cf +=
<_JsonReader_PD_{key}>{val};
}

payloadXML.cf = customFieldsTag;

mc.setPayloadXML(payloadXML);

However, when processing the payload via XML, when there is only one element
within a JSON array, e.g. {"jsonaray" : ["some value"]}

this is processed as a single value (not within an array) and sent by the
XML processor as {"jsonarray" : "some value"}

Furthermore, when sending an empty value within a JSON array (which is
required by the backend) and processing using XML, e.g. {"jsonarray" :
["some value", ""]}, the empty value is converted to *null*, which is not
accepted by the backend. 


I would appreciate if someone could give me a solution to either;
* Send numeric keys and values as strings within a JSON payload without them
being processed in to numeric primitives.
* Send a single value within a JSON array without it being reprocessed as a
single key value pair by the XML-to-JSON processor. 


Thanks,




--
View this message in context: 
http://wso2-oxygen-tank.10903.n7.nabble.com/ESB-Problems-sending-numeric-keys-in-JSON-Payloads-tp99789.html
Sent from the WSO2 Development mailing list archive at Nabble.com.
___
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev


Re: [Dev] [ESB] Problems sending numeric keys in JSON Payloads

2014-07-22 Thread Malaka Silva
Hi,

Can you try adding  (Processing Instruction) element to the
payload and check.

Best Regards,
Malaka


On Mon, Jul 21, 2014 at 2:27 PM, Jay  wrote:

> Hi,
>
> I am calling an endpoint which requires sending numeric keys in objects in
> the following format:
> {"1" : "some value"}
>
> However, when processing this using a script mediator, the numeric key is
> converted in to a primitive number as follows:
> {1 : "some value"}
>
> which is not accepted by the script mediator when setting the payload using
> setPayloadJSON.
>
> This problem can also be seen when sending numeric values (not keys).
> Although the values are numeric, the backend does not accept these values
> if
> they are not sent as strings. e.g. {"key":"123"} is converted to
> {"key":123}
> which is not accepted.
>
>
> I managed to circumvent this problem by processing the payload via XML:
>
> payloadXML = mc.getPayloadXML();
> var customFields =
> mc.getProperty("uri.var.customFields");
>
> var jsonObj =
> eval("("+customFields+")");
> var customFieldsTag = ;
> for(var key in  jsonObj){
> var val = jsonObj[key];
> customFieldsTag.cf +=
> <_JsonReader_PD_{key}>{val};
> }
>
> payloadXML.cf = customFieldsTag;
>
> mc.setPayloadXML(payloadXML);
>
> However, when processing the payload via XML, when there is only one
> element
> within a JSON array, e.g. {"jsonaray" : ["some value"]}
>
> this is processed as a single value (not within an array) and sent by the
> XML processor as {"jsonarray" : "some value"}
>
> Furthermore, when sending an empty value within a JSON array (which is
> required by the backend) and processing using XML, e.g. {"jsonarray" :
> ["some value", ""]}, the empty value is converted to *null*, which is not
> accepted by the backend.
>
>
> I would appreciate if someone could give me a solution to either;
> * Send numeric keys and values as strings within a JSON payload without
> them
> being processed in to numeric primitives.
> * Send a single value within a JSON array without it being reprocessed as a
> single key value pair by the XML-to-JSON processor.
>
>
> Thanks,
>
>
>
>
> --
> View this message in context:
> http://wso2-oxygen-tank.10903.n7.nabble.com/ESB-Problems-sending-numeric-keys-in-JSON-Payloads-tp99789.html
> Sent from the WSO2 Development mailing list archive at Nabble.com.
> ___
> Dev mailing list
> Dev@wso2.org
> 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/


Save a tree -Conserve nature & Save the world for your future. Print this
email only if it is absolutely necessary.
___
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev


Re: [Dev] [ESB] Problems sending numeric keys in JSON Payloads

2014-07-23 Thread Jay
Hi Malaka,

I have tried with your solution but it didn't work. 

following is my javascript code:

var
tagElement=TestTag;

payloadXML.tags=tagElement;

This will create JSON payload as : 

{"tags":"TestTag"}

But the requirement is:
 {"tags":["TestTag"]}

I have enabled following message builder/formatter as well,




Regards,
Janaka



--
View this message in context: 
http://wso2-oxygen-tank.10903.n7.nabble.com/ESB-Problems-sending-numeric-keys-in-JSON-Payloads-tp99789p11.html
Sent from the WSO2 Development mailing list archive at Nabble.com.
___
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev


Re: [Dev] [ESB] Problems sending numeric keys in JSON Payloads

2014-07-24 Thread Malaka Silva
Hi,

Try following

var tagElement=
TestTag;



On Wed, Jul 23, 2014 at 1:52 PM, Jay  wrote:

> Hi Malaka,
>
> I have tried with your solution but it didn't work.
>
> following is my javascript code:
>
> var
> tagElement=TestTag;
>
> payloadXML.tags=tagElement;
>
> This will create JSON payload as :
>
> {"tags":"TestTag"}
>
> But the requirement is:
>  {"tags":["TestTag"]}
>
> I have enabled following message builder/formatter as well,
>
> 
> class="org.apache.synapse.commons.json.JsonFormatter"/>
> 
> class="org.apache.synapse.commons.json.JsonBuilder"/>
>
> Regards,
> Janaka
>
>
>
> --
> View this message in context:
> http://wso2-oxygen-tank.10903.n7.nabble.com/ESB-Problems-sending-numeric-keys-in-JSON-Payloads-tp99789p11.html
> Sent from the WSO2 Development mailing list archive at Nabble.com.
> ___
> Dev mailing list
> Dev@wso2.org
> 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/


Save a tree -Conserve nature & Save the world for your future. Print this
email only if it is absolutely necessary.
___
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev


Re: [Dev] [ESB] Problems sending numeric keys in JSON Payloads

2014-07-24 Thread Jay
Hi Malaka,

I tried with this and still having a problem.

var
a=TestTag;

Output:

"jsonObject":{"tags":"TestTag"}

Regards,
Janaka


On Thu, Jul 24, 2014 at 5:50 PM, Malaka Silva [via WSO2 Oxygen Tank] <
ml-node+s10903n100231...@n7.nabble.com> wrote:

> Hi,
>
> Try following
>
> var tagElement=
> TestTag;
>
>
>
> On Wed, Jul 23, 2014 at 1:52 PM, Jay <[hidden email]
> > wrote:
>
>> Hi Malaka,
>>
>> I have tried with your solution but it didn't work.
>>
>> following is my javascript code:
>>
>> var
>>
>> tagElement=TestTag;
>>
>> payloadXML.tags=tagElement;
>>
>> This will create JSON payload as :
>>
>> {"tags":"TestTag"}
>>
>> But the requirement is:
>>  {"tags":["TestTag"]}
>>
>> I have enabled following message builder/formatter as well,
>>
>> >
>> class="org.apache.synapse.commons.json.JsonFormatter"/>
>> >
>> class="org.apache.synapse.commons.json.JsonBuilder"/>
>>
>> Regards,
>> Janaka
>>
>>
>>
>> --
>> View this message in context:
>> http://wso2-oxygen-tank.10903.n7.nabble.com/ESB-Problems-sending-numeric-keys-in-JSON-Payloads-tp99789p11.html
>> Sent from the WSO2 Development mailing list archive at Nabble.com.
>> ___
>> Dev mailing list
>> [hidden email] 
>> 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/
> 
>
> Save a tree -Conserve nature & Save the world for your future. Print this
> email only if it is absolutely necessary.
>
> ___
> Dev mailing list
> [hidden email] 
> http://wso2.org/cgi-bin/mailman/listinfo/dev
>
>
> --
>  If you reply to this email, your message will be added to the discussion
> below:
>
> http://wso2-oxygen-tank.10903.n7.nabble.com/ESB-Problems-sending-numeric-keys-in-JSON-Payloads-tp99789p100231.html
>  To unsubscribe from [ESB] Problems sending numeric keys in JSON Payloads, 
> click
> here
> 
> .
> NAML
> 
>



-- 
 *Janaka Ranathunga* * Senior Software Engineer*
  Tel: +94 11 256 9150  | Mobile: +94 71 168 3232
 janaka.n.ranathu...@gmail.com







--
View this message in context: 
http://wso2-oxygen-tank.10903.n7.nabble.com/ESB-Problems-sending-numeric-keys-in-JSON-Payloads-tp99789p100277.html
Sent from the WSO2 Development mailing list archive at Nabble.com.___
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev


Re: [Dev] [ESB] Problems sending numeric keys in JSON Payloads

2014-08-11 Thread Malaka Silva
Hi,

Observe the following logs. This works. output was {"tags":["TestTag"]}

Log:-

[2014-08-12 11:00:28,104]  INFO - LogMediator To:
/services/pass.passHttpSoap12Endpoint, WSAction: urn:mediate, SOAPAction:
urn:mediate, MessageID: urn:uuid:d3d3208b-7059-4266-8835-69b616d6c247,
Direction: request, Envelope: http://www.w3.org/2003/05/soap-envelope";>TestTag
[2014-08-12 11:00:28,106] DEBUG - wire << "POST /service/echo
HTTP/1.1[\r][\n]"
[2014-08-12 11:00:28,106] DEBUG - wire << "Content-Type: application/json;
charset=UTF-8[\r][\n]"
[2014-08-12 11:00:28,106] DEBUG - wire << "Transfer-Encoding:
chunked[\r][\n]"
[2014-08-12 11:00:28,106] DEBUG - wire << "Host: localhost:9000[\r][\n]"
[2014-08-12 11:00:28,106] DEBUG - wire << "Connection: Keep-Alive[\r][\n]"
[2014-08-12 11:00:28,106] DEBUG - wire << "User-Agent:
Synapse-HttpComponents-NIO[\r][\n]"
[2014-08-12 11:00:28,106] DEBUG - wire << "[\r][\n]"
[2014-08-12 11:00:28,107] DEBUG - wire << "14[\r][\n]"
[2014-08-12 11:00:28,107] DEBUG - wire << "{"tags":["TestTag"]}[\r][\n]"
[2014-08-12 11:00:28,107] DEBUG - wire << "0[\r][\n]"
[2014-08-12 11:00:28,107] DEBUG - wire << "[\r][\n]"

Config:-

 

   
 TestTag
  
   


 
 
 


On Fri, Jul 25, 2014 at 11:27 AM, Jay  wrote:

> Hi Malaka,
>
> I tried with this and still having a problem.
>
> var
> a=TestTag;
>
> Output:
>
> "jsonObject":{"tags":"TestTag"}
>
> Regards,
> Janaka
>
>
> On Thu, Jul 24, 2014 at 5:50 PM, Malaka Silva [via WSO2 Oxygen Tank] <[hidden
> email] <http://user/SendEmail.jtp?type=node&node=100277&i=0>> wrote:
>
>> Hi,
>>
>> Try following
>>
>> var tagElement=
>> TestTag;
>>
>>
>>
>> On Wed, Jul 23, 2014 at 1:52 PM, Jay <[hidden email]
>> <http://user/SendEmail.jtp?type=node&node=100231&i=0>> wrote:
>>
>>> Hi Malaka,
>>>
>>> I have tried with your solution but it didn't work.
>>>
>>> following is my javascript code:
>>>
>>> var
>>>
>>> tagElement=TestTag;
>>>
>>> payloadXML.tags=tagElement;
>>>
>>> This will create JSON payload as :
>>>
>>> {"tags":"TestTag"}
>>>
>>> But the requirement is:
>>>  {"tags":["TestTag"]}
>>>
>>> I have enabled following message builder/formatter as well,
>>>
>>> >>
>>> class="org.apache.synapse.commons.json.JsonFormatter"/>
>>> >>
>>> class="org.apache.synapse.commons.json.JsonBuilder"/>
>>>
>>> Regards,
>>> Janaka
>>>
>>>
>>>
>>> --
>>> View this message in context:
>>> http://wso2-oxygen-tank.10903.n7.nabble.com/ESB-Problems-sending-numeric-keys-in-JSON-Payloads-tp99789p11.html
>>> Sent from the WSO2 Development mailing list archive at Nabble.com.
>>> ___
>>> Dev mailing list
>>> [hidden email] <http://user/SendEmail.jtp?type=node&node=100231&i=1>
>>> http://wso2.org/cgi-bin/mailman/listinfo/dev
>>>
>>
>>
>>
>> --
>>
>> Best Regards,
>>
>> Malaka Silva
>> Senior Tech Lead
>> M: > target="_blank">+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
>> [hidden email] <http://user/SendEmail.jtp?type=node&node=100231&i=2>
>> http://wso2.org/cgi-bin/mailman/listinfo/dev
>>
>>
>> --------------
>>  If you reply to this email, your message will be added to the
>> discussion below:
>>
>> http://wso2-oxygen-tank.10903.n7.nabble.com/ESB-Problems-sending-numeric

Re: [Dev] [ESB] Problems sending numeric keys in JSON Payloads

2014-08-11 Thread Jay
Hi Malaka, 

I have already tried this solution and this will work only if we declared
 in payloadFactory mediator. But if i set 
in script mediator it will ignore. Following is my complete config:






TestTag

Janaka







 







And the output:

[2014-08-12 12:17:41,485]  INFO - LogMediator To:
/services/ClevertimCRM_createOpportunity, MessageID: urn:uuid:73a98f19
-1a7e-4fbe-ba68-2ef530419845, Direction: request, Envelope: http://schemas.xmlsoap.org/soap/envelope/";>Tes
tTagJanakaTestTag

[2014-08-12 12:17:41,486]  INFO - LogMediator To:
/services/ClevertimCRM_createOpportunity, MessageID: urn:uuid:73a98f19
-1a7e-4fbe-ba68-2ef530419845, Direction: request, Janaka =
{"tags":["TestTag"],"name":"Janaka","scriptArray":"TestTag"}

I need to send "scriptArray" also as an array.

Regards,
Janaka



--
View this message in context: 
http://wso2-oxygen-tank.10903.n7.nabble.com/ESB-Problems-sending-numeric-keys-in-JSON-Payloads-tp99789p101240.html
Sent from the WSO2 Development mailing list archive at Nabble.com.
___
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev


Re: [Dev] [ESB] Problems sending numeric keys in JSON Payloads

2014-08-12 Thread Malaka Silva
Please share your configuration with the script mediator.



On Tue, Aug 12, 2014 at 12:23 PM, Jay  wrote:

> Hi Malaka,
>
> I have already tried this solution and this will work only if we declared
>  in payloadFactory mediator. But if i set 
> in script mediator it will ignore. Following is my complete config:
>
> 
> 
> 
> 
>
> TestTag
> 
> Janaka
> 
>
> 
> 
> 
>
>
>
>  scope="axis2"
> type="STRING" />
> 
>
> 
>  />
> 
>
> And the output:
>
> [2014-08-12 12:17:41,485]  INFO - LogMediator To:
> /services/ClevertimCRM_createOpportunity, MessageID: urn:uuid:73a98f19
> -1a7e-4fbe-ba68-2ef530419845, Direction: request, Envelope:  version="1.0" encoding="utf-8"?> s:soapenv="http://schemas.xmlsoap.org/soap/envelope/
> "> ?>Tes
>
> tTagJanakaTestTag soapenv:Body>
>
> [2014-08-12 12:17:41,486]  INFO - LogMediator To:
> /services/ClevertimCRM_createOpportunity, MessageID: urn:uuid:73a98f19
> -1a7e-4fbe-ba68-2ef530419845, Direction: request, Janaka =
> {"tags":["TestTag"],"name":"Janaka","scriptArray":"TestTag"}
>
> I need to send "scriptArray" also as an array.
>
> Regards,
> Janaka
>
>
>
> --
> View this message in context:
> http://wso2-oxygen-tank.10903.n7.nabble.com/ESB-Problems-sending-numeric-keys-in-JSON-Payloads-tp99789p101240.html
> Sent from the WSO2 Development mailing list archive at Nabble.com.
> ___
> Dev mailing list
> Dev@wso2.org
> 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/


Save a tree -Conserve nature & Save the world for your future. Print this
email only if it is absolutely necessary.
___
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev


Re: [Dev] [ESB] Problems sending numeric keys in JSON Payloads

2014-08-12 Thread Jay
Hi Malaka,

Following is my configuration with inline script mediator: 


http://ws.apache.org/ns/synapse";>





TestTag

Janaka






**
 





















--
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
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev


Re: [Dev] [ESB] Problems sending numeric keys in JSON Payloads

2014-08-12 Thread Malaka Silva
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 >> "http://www.w3.org/2003/05/soap-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: http://www.w3.org/2003/05/soap-envelope";>TestTagJanaka
[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

Re: [Dev] [ESB] Problems sending numeric keys in JSON Payloads

2014-08-12 Thread Malaka Silva
Hi,

My understanding is your requirement is to achieve {"tags":["TestTag"]}

you can easily done this with following. Combining payload mediator and
script mediator.

 

   


 
 payloadXML = mc.getPayloadXML();
 payloadXML.jsonObject +=
<?xml-multiple?><tags><jsonElement>TestTag</jsonElement></tags&gt;
 print(payloadXML);
 mc.setPayloadXML(payloadXML);

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  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 >> " encoding="UTF-8"?>http://www.w3.org/2003/05/soap-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:  encoding="utf-8"?>http://www.w3.org/2003/05/soap-envelope";>  
> ?>TestTagJanaka
> [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 >> "Conten

Re: [Dev] [ESB] Problems sending numeric keys in JSON Payloads

2014-08-13 Thread Jay
Hi Malaka,

My initial payload is as follows:




Janaka
Desc
open
A
LKR
114520







In script I'm adding some additional parameters (value and tags.tags should
be send as array even if there are only one) to above payload as:

**

This will work properly if user send tags in request. But my problem is if
user doesn't send tags parameter "tags" element will remove from payload and
 is applying to value element and it will send as array
which back end will not accept. I have two options,
[1]. Remove  from payload if user doesn't send any tags
[2]. Add PIs in Script mediator  other than in payloadFactory.

What is your idea to solve this problem?

Regards,
Janaka 



--
View this message in context: 
http://wso2-oxygen-tank.10903.n7.nabble.com/ESB-Problems-sending-numeric-keys-in-JSON-Payloads-tp99789p101325.html
Sent from the WSO2 Development mailing list archive at Nabble.com.
___
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev


Re: [Dev] [ESB] Problems sending numeric keys in JSON Payloads

2014-08-18 Thread Malaka Silva
Hi,

If any of the above does not work use a class mediator to do generate the
json payload required.

eg:-

public boolean mediate(MessageContext mc) {
StringBuilder sb = new StringBuilder();

//generate the required payload

org.apache.axis2.context.MessageContext axis2MC =
((Axis2MessageContext)mc).getAxis2MessageContext();
JsonUtil.newJsonPayload(axis2MC, sb.toString(), true, true);
return true;
}

[1] https://docs.wso2.com/display/ESB481/Class+Mediator

Best Regards,
Malaka


On Wed, Aug 13, 2014 at 1:18 PM, Jay  wrote:

> Hi Malaka,
>
> My initial payload is as follows:
>
> 
> 
> 
> Janaka
> Desc
> open
> A
> LKR
> 114520
> 
> 
>
> 
> 
> 
>
> In script I'm adding some additional parameters (value and tags.tags should
> be send as array even if there are only one) to above payload as:
>
> **
>
> This will work properly if user send tags in request. But my problem is if
> user doesn't send tags parameter "tags" element will remove from payload
> and
>  is applying to value element and it will send as array
> which back end will not accept. I have two options,
> [1]. Remove  from payload if user doesn't send any tags
> [2]. Add PIs in Script mediator  other than in payloadFactory.
>
> What is your idea to solve this problem?
>
> Regards,
> Janaka
>
>
>
> --
> View this message in context:
> http://wso2-oxygen-tank.10903.n7.nabble.com/ESB-Problems-sending-numeric-keys-in-JSON-Payloads-tp99789p101325.html
> Sent from the WSO2 Development mailing list archive at Nabble.com.
> ___
> Dev mailing list
> Dev@wso2.org
> 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/


Save a tree -Conserve nature & Save the world for your future. Print this
email only if it is absolutely necessary.
___
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev