【问题标题】:WSO2 Enterprise Integrater 6.6.0 Response transform XML to Json using XSLTWSO2 Enterprise Integrator 6.6.0 使用 XSLT 将 XML 响应转换为 Json
【发布时间】:2020-12-01 02:09:41
【问题描述】:

我收到了来自 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
    
}

【问题讨论】:

    标签: json xml xslt transformation wso2ei


    【解决方案1】:

    您可以使用数据映射器调解器 [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

    【讨论】:

      猜你喜欢
      • 2023-03-28
      • 2020-01-26
      • 2023-03-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多