有没有办法将XML RPC映射到Json?
这是我在我的终端上得到的回复。
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>
但是在映射器中,他们将值分组为数组
我是wso2 esb的新手,我没有找到任何关于它的文档。
此服务的XML RPC是纯数组索引,例如:for get OrderID
是['Result'][0][0]
(成员,数组,数组)。
因此可以使用数组索引与json元素绑定吗?
如果无法使用mapper,我该怎么办?
== UPDATE ==
.dmc文件
var arrayIndex = 0;
map_S_methodResponse_S_root = function(){
var outputroot={};
var COMPARE_61_0 = '';
var COMPARE_62_0 = '';
var COMPARE_63_0 = '';
var COMPARE_64_0 = '';
var COMPARE_65_0 = '';
var COMPARE_66_0 = '';
var COMPARE_67_0 = '';
var COMPARE_68_0 = '';
var COMPARE_69_0 = '';
var COMPARE_70_0 = '';
var COMPARE_71_0 = '';
var COMPARE_72_0 = '';
var COMPARE_73_0 = '';
var COMPARE_74_0 = '';
var COMPARE_75_0 = '';
var COMPARE_76_0 = '';
var COMPARE_77_0 = '';
var COMPARE_78_0 = '';
var COMPARE_79_0 = '';
var IF_ELSE_23_0 = '';
var IF_ELSE_25_0 = '';
var IF_ELSE_27_0 = '';
var IF_ELSE_29_0 = '';
var IF_ELSE_31_0 = '';
var IF_ELSE_33_0 = '';
var IF_ELSE_35_0 = '';
var IF_ELSE_37_0 = '';
var IF_ELSE_39_0 = '';
var IF_ELSE_41_0 = '';
var IF_ELSE_43_0 = '';
var IF_ELSE_45_0 = '';
var IF_ELSE_47_0 = '';
var IF_ELSE_49_0 = '';
var IF_ELSE_51_0 = '';
var IF_ELSE_53_0 = '';
var IF_ELSE_55_0 = '';
var IF_ELSE_57_0 = '';
var IF_ELSE_59_0 = '';
var count_i_value = 0;
COMPARE_61_0 = ( arrayIndex === 0 );
COMPARE_62_0 = ( arrayIndex === 1 );
COMPARE_63_0 = ( arrayIndex === 2 );
COMPARE_64_0 = ( arrayIndex === 3 );
COMPARE_65_0 = ( arrayIndex === 4 );
COMPARE_66_0 = ( arrayIndex === 5 );
COMPARE_67_0 = ( arrayIndex === 6 );
COMPARE_68_0 = ( arrayIndex === 7 );
COMPARE_69_0 = ( arrayIndex === 8 );
COMPARE_70_0 = ( arrayIndex === 9 );
COMPARE_71_0 = ( arrayIndex === 10 );
COMPARE_72_0 = ( arrayIndex === 11 );
COMPARE_73_0 = ( arrayIndex === 12 );
COMPARE_74_0 = ( arrayIndex === 13 );
COMPARE_75_0 = ( arrayIndex === 14 );
COMPARE_76_0 = ( arrayIndex === 15 );
COMPARE_77_0 = ( arrayIndex === 16 );
COMPARE_78_0 = ( arrayIndex === 17 );
COMPARE_79_0 = ( arrayIndex === 18 );
outputroot = {};
outputroot.Result = {};
for(i_value in inputmethodResponse.params.param.value.struct.member.value.array.data.value.array.data.value){
IF_ELSE_23_0 = (COMPARE_69_0)?(inputmethodResponse.params.param.value.struct.member.value.array.data.value.array.data.value[i_value].double):(IF_ELSE_23_0);
IF_ELSE_25_0 = (COMPARE_70_0)?(inputmethodResponse.params.param.value.struct.member.value.array.data.value.array.data.value[i_value].double):(IF_ELSE_25_0);
IF_ELSE_27_0 = (COMPARE_71_0)?(inputmethodResponse.params.param.value.struct.member.value.array.data.value.array.data.value[i_value].double):(IF_ELSE_27_0);
IF_ELSE_29_0 = (COMPARE_72_0)?(inputmethodResponse.params.param.value.struct.member.value.array.data.value.array.data.value[i_value].double):(IF_ELSE_29_0);
IF_ELSE_31_0 = (COMPARE_62_0)?(inputmethodResponse.params.param.value.struct.member.value.array.data.value.array.data.value[i_value].string):(IF_ELSE_31_0);
IF_ELSE_33_0 = (COMPARE_65_0)?(inputmethodResponse.params.param.value.struct.member.value.array.data.value.array.data.value[i_value].string):(IF_ELSE_33_0);
IF_ELSE_35_0 = (COMPARE_66_0)?(inputmethodResponse.params.param.value.struct.member.value.array.data.value.array.data.value[i_value].string):(IF_ELSE_35_0);
IF_ELSE_37_0 = (COMPARE_73_0)?(inputmethodResponse.params.param.value.struct.member.value.array.data.value.array.data.value[i_value].string):(IF_ELSE_37_0);
IF_ELSE_39_0 = (COMPARE_75_0)?(inputmethodResponse.params.param.value.struct.member.value.array.data.value.array.data.value[i_value].string):(IF_ELSE_39_0);
IF_ELSE_41_0 = (COMPARE_76_0)?(inputmethodResponse.params.param.value.struct.member.value.array.data.value.array.data.value[i_value].string):(IF_ELSE_41_0);
IF_ELSE_43_0 = (COMPARE_77_0)?(inputmethodResponse.params.param.value.struct.member.value.array.data.value.array.data.value[i_value].string):(IF_ELSE_43_0);
IF_ELSE_45_0 = (COMPARE_78_0)?(inputmethodResponse.params.param.value.struct.member.value.array.data.value.array.data.value[i_value].string):(IF_ELSE_45_0);
IF_ELSE_47_0 = (COMPARE_61_0)?(inputmethodResponse.params.param.value.struct.member.value.array.data.value.array.data.value[i_value].i4):(IF_ELSE_47_0);
IF_ELSE_49_0 = (COMPARE_63_0)?(inputmethodResponse.params.param.value.struct.member.value.array.data.value.array.data.value[i_value].i4):(IF_ELSE_49_0);
IF_ELSE_51_0 = (COMPARE_64_0)?(inputmethodResponse.params.param.value.struct.member.value.array.data.value.array.data.value[i_value].i4):(IF_ELSE_51_0);
IF_ELSE_53_0 = (COMPARE_67_0)?(inputmethodResponse.params.param.value.struct.member.value.array.data.value.array.data.value[i_value].i4):(IF_ELSE_53_0);
IF_ELSE_55_0 = (COMPARE_68_0)?(inputmethodResponse.params.param.value.struct.member.value.array.data.value.array.data.value[i_value].i4):(IF_ELSE_55_0);
IF_ELSE_57_0 = (COMPARE_74_0)?(inputmethodResponse.params.param.value.struct.member.value.array.data.value.array.data.value[i_value].i4):(IF_ELSE_57_0);
IF_ELSE_59_0 = (COMPARE_79_0)?(inputmethodResponse.params.param.value.struct.member.value.array.data.value.array.data.value[i_value].i4):(IF_ELSE_59_0);
outputroot.Result.OrderID = IF_ELSE_47_0;
outputroot.Result.OrderNumber = IF_ELSE_31_0;
outputroot.Result.VendorAccountID = IF_ELSE_49_0;
outputroot.Result.AccountID = IF_ELSE_51_0;
outputroot.Result.OrderStatusID = IF_ELSE_33_0;
outputroot.Result.OrderTypeID = IF_ELSE_35_0;
outputroot.Result.CreationTime = IF_ELSE_53_0;
outputroot.Result.CreationDate = IF_ELSE_55_0;
outputroot.Result.CompletedDate = IF_ELSE_59_0;
outputroot.Result.ExpirationDate = IF_ELSE_57_0;
outputroot.Result.CurrencyID = IF_ELSE_45_0;
outputroot.Result.OrderTotal = IF_ELSE_23_0;
outputroot.Result.TaxTotal = IF_ELSE_25_0;
outputroot.Result.DiscountTotal = IF_ELSE_27_0;
outputroot.Result.MerchTotal = IF_ELSE_29_0;
outputroot.Result.Description = IF_ELSE_37_0;
outputroot.Result.PromoCode = IF_ELSE_39_0;
outputroot.Result.SalesBranchID = IF_ELSE_41_0;
outputroot.Result.SalesPersonID = IF_ELSE_43_0;
count_i_value++;
}
return outputroot;
};
arrayIndex = function(val){ arrayIndex++;};
我换了之后工作了,例如,(COMPARE_61_0)? for(count_i_value == 0)?在de for。
答案 0 :(得分:1)
可以这样做。由于在这个数据映射器版本中我们无法处理映射中的对象或数组,因此我们必须使用自定义函数和全局变量来解决这个问题。但我认为它有望在下一版数据映射器中出现。现在,您可以使用自定义函数迭代全局变量,并找到索引并将其分配给输出元素,如附图所示。