json - WSO2 Enterprise Integrator 6.6.0 使用 XSLT 将 XML 响应转换为 Json
问题描述
我从 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
推荐阅读
- javascript - 在javascript中计数和重置
- javascript - 使用纯javascript将鼠标悬停在视频上时如何播放视频
- ruby - 向 Middleman 添加自定义 Markdown
- c# - 用一个词多次拆分字符串?
- html - 在换行符中处理边距时,是否有更简单的“calc”替代方法?
- video-streaming - HLS 视频流和聊天消息同步
- ios - 将 AKAudioFile 拆分为由静音分隔的块
- vb.net - VB.NET 不能将 EOF 和 BOF 与 ADODB 记录集一起使用
- typescript - TypeScript:条件类型并使用布尔参数来控制返回类型
- sql-server - 字符串或二进制数据将从 SQL Server 截断到 PostgreSQL 链接服务器