【问题标题】:Return SOAP response using WSO2 when invoking an API调用 API 时使用 WSO2 返回 SOAP 响应
【发布时间】:2022-12-17 17:53:48
【问题描述】:

我使用返回 JSON 对象的 WSO2 数据服务创建了一个 API,我的客户端应用程序等待 SOAP 响应而不是 json 响应,所以我尝试使用数据映射器将响应格式从 JSON 更改为 SOAP,但它只返回 XML 格式没有 SOAP Body 和 SOAP 信封。如何解决这个问题?

这是我想要获得的 SOAP 响应格式:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<GetFacturesClientResponse xmlns="http://tempuri.org/">
<GetFacturesClientResult>
<code>0</code>
<codeClient>P-2008-043681</codeClient>
<nom>na</nom>
<prenom>ouss</prenom>
</GetFacturesClientResult>
</GetFacturesClientResponse>
</soap:Body>
</soap:Envelope>

但我得到了这样的回应:

<GetFacturesClientResponse xmlns="http://tempuri.org/">
<GetFacturesClientResult>
<code>0</code>
<codeClient>P-2008-043681</codeClient>
<nom>na</nom>
<prenom>ouss</prenom>
</GetFacturesClientResult>
</GetFacturesClientResponse>

这是我的代码:

            <datamapper config="gov:datamapper/oussama.dmc" inputSchema="gov:datamapper/oussama_inputSchema.json" inputType="JSON" outputSchema="gov:datamapper/oussama_outputSchema.json" outputType="JSON" xsltStyleSheet="gov:datamapper/oussama_xsltStyleSheet.xml"/>

【问题讨论】:

    标签: soap wso2 wso2-esb wso2-enterprise-integrator wso2-data-services-server


    【解决方案1】:

    您也可以尝试使用 XSLT 调解器来实现这一点。试试下面的例子:

    https://apim.docs.wso2.com/en/latest/integrate/examples/message_transformation_examples/json-to-soap-conversion/

    【讨论】:

      猜你喜欢
      • 2020-02-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-02-27
      • 1970-01-01
      相关资源
      最近更新 更多