![](/img/trans.png)
[英]wso2 api - Cannot retrieve response with content type [application/xml]
[英]Return SOAP response using WSO2 when invoking an API
我使用返回 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"/>
在Respond Mediator
之前設置以下屬性。
<property name="messageType" value="application/soap+xml" scope="axis2"/>
同樣在您的 Datamapper 部分中, outputType="XML"
不是 JSON。
更新
正如蛇夫提到的。 上述內容類型將創建 SOAP 1.2 消息,如果您需要 SOAP 1.1 消息,請將內容類型設置為text/xml
。 通常,客戶端支持這兩個版本。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.