-1
我有一個包含CDATA的soap響應,但是我在java中處理響應的所有開始引用(<)都被替換爲(<)。如何用Java SOAP響應中的(<)替換(<)SAAJ
這裏是響應應該怎麼看起來像
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<ns:Response xmlns:ns="http://pipeline_ws">
<ns:return>
<![CDATA[<fr><Result>
<ListPartner>
<operator>
<country_code></country_code>
<currency_code></currency_code>
<operator_code></operator_code>
</operator>
</ListPartner>
</Result></fr>]]></ns:return>
</ns:Response>
</soapenv:Body>
</soapenv:Envelope>
而是這是我得到
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<ns:Response xmlns:ns="http://pipeline_ws">
<ns:return>
<fr>
<Result>
<ListPartner>
<operator>
<country_code></country_code>
<currency_code></currency_code>
<operator_code></operator_code>
</operator>
</ListPartner>
</Result>
</fr>
</ns:return>
</ns:Response>
</soapenv:Body>
</soapenv:Envelope>
請提供一個解決方案,刪除/替換不需要的字符幫助響應(< )所以我可以解析迴應。我使用SAAJ來處理響應
// Process the SOAP Response
SOAPMessage soapResponse = soapConnection.call(createSOAPRequest(), url);
soapResponse.writeTo(System.out);
兩個序列化實際上是相同的。您的結果將以字符串形式返回,而不是真正的XML。如果您對服務有控制權,您應該將其更改爲發送真正的XML。 – vanje
@vanje我無法控制服務,所以我無法更改對XML的響應。 –