Rodolpho Freire Rodolpho Freire - 1 month ago 15
JSON Question

Data mapping XML RPC to JSON

Is there a way to mapping a XML RPC to Json?

This is the response I get on my endpoint.

https://download.automation.odin.com/pa/6.0/doc/portal/6.0/ba/index.htm?fileName=75131.htm

<?xml version="1.0"?>
<methodResponse>
<params>
<param>
<value>
<struct>
<member>
<name>Result</name>
<value>
<array>
<data>
<value>
<array>
<data>
<!-- OrderID -->
<value>
<i4>16</i4>
</value>
<!-- Order Number -->
<value>
<string>SO000008</string>
</value>
<!-- Vendor Account ID-->
<value>
<i4>1</i4>
</value>
<!-- Customer Account ID-->
<value>
<i4>1000002</i4>
</value>
<!-- Order Status ID-->
<value>
<string>WP</string>
</value>
<!-- Order Type ID-->
<value>
<string>SO</string>
</value>
<!-- Order Creation Time-->
<value>
<i4>1245328433</i4>
</value>
<!-- Order Creation Date-->
<value>
<i4>1245268800</i4>
</value>
<!-- Order Total -->
<value>
<double>85.000000</double>
</value>
<!-- Order Tax Total -->
<value>
<double>0.000000</double>
</value>
<!-- Discount Total -->
<value>
<double>0.000000</double>
</value>
<!-- Order MerchTotal -->
<value>
<double>85.000000</double>
</value>
<!-- Order Description -->
<value>
<string>
Subscription for Plan 3 (Linux Basic) for 1 Year(s).
</string>
</value>
<!-- Order Expiration Date-->
<value>
<i4>1245528000</i4>
</value>
<!-- Promo Code-->
<value>
<string/>
</value>
<!-- Sales Branch ID-->
<value>
<string>2</string>
</value>
<!-- Sales Person ID-->
<value>
<string>1</string>
</value>
<!-- CurrencyID-->
<value>
<string>USD</string>
</value>
<!-- CompletedDate-->
<value>
<i4>1453805121</i4>
</value>
</data>
</array>
</value>
</data>
</array>
</value>
</member>
</struct>
</value>
</param>
</params>




But in the mapper they group the value as an array

ESB Tooling Data Mapper

I am new to wso2 esb, and I didn't find any documentation about it.

The XML RPC for this service is purelly array index, e.g.: for get
OrderID
is
['Result'][0][0]
(member, array, array).

So is it possible to use array indexes for bind with json elements??

If with mapper is not possible how can I do it?

Answer

It is possible to do it. Since in this data mapper version we can not handle objects or arrays in the mapping we have to use a kind of work around for that with the use of custom functions and global variables. But i think it will be in the next release of the data mapper hopefully. For now you can iterate a global variable using a custom function and find the index and assign it to the output element as showed in the attached image.

enter image description here

Comments