问题描述
我收到了WSO2企业集成器中的端点作为XML的回复。我也可以作为Json获得它。但是我需要为我的客户端应用程序做出适当的响应(添加更多参数)。这是我从端点获得的xml响应。
<jsonObject>
<ddd>
<__type>Title</__type>
<AccountNo/>
<AccountExists>1</AccountExists>
<Name>user name</ConsumerName>
<Address> user address</ConsumerAddress>
<TotalDue>1000.38</TotalDue>
<LastBillingCycleAmount/>
<ID>150</ID>
</d>
这也是我可以从端点检索的json输出
{
"ddd": {
"__type": "Title","AccountNo": null,"AccountExists": 1,"Name": "user name","Address": "address","TotalDue": "1000.38","LastBillingCycleAmount": null,"ID": 150
}
}
我需要这样的变换响应。
{
"AccountNo": "response_data","ConsumerName": "response_data","ConsumerAddress": "response_data","TotalDue": "response_data","additional_para1": "my_data",// parameter that i want to add manually
"additional_para2": "my_data",// parameter that i want to add manually
}
解决方法
您可以使用数据映射器介体[1]将输入映射到所需的输出。然后使用丰富介体[2]通过添加您自己的值来丰富生成的有效负载
[1] -https://ei.docs.wso2.com/en/7.1.0/micro-integrator/references/mediators/data-Mapper-Mediator/
[2] -https://docs.wso2.com/display/EI620/Enrich+Mediator