【发布时间】:2018-05-21 11:14:33
【问题描述】:
我需要将一个肥皂响应 xml 转换为一个 JAVA 对象以迎合另一个服务。 SOAP 响应看起来像
<?xml version="1.0" encoding="UTF-8"?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns2:myResponse xmlns:ns2="http://impl.service.abc.com/">
<return>
<response>
<timestamp>11068446</timestamp>
<txnAmount>1</txnAmount>
<userGuid>11068446</userGuid>
<walletSystemTxnId>123456789</walletSystemTxnId>
</response>
<status>SUCCESSS</status>
<statusCode>SUCCESS</statusCode>
<statusMessage>SUCCESS</statusMessage>
</return>
</ns2:myResponse>
</S:Body>
</S:Envelope>
我尝试了很多方法来转换读取它并将其转换为我的类实例。
我如何调用soapservice。 我正在调用使用spring框架的webService模板的soapService。 代码是
SOAPConnectionFactory soapConnectionFactory = SOAPConnectionFactory.newInstance();
SOAPConnection soapConnection = soapConnectionFactory.createConnection();
//Send SOAP Message to SOAP Server
SOAPMessage soapResponse = soapConnection.call(createSOAPRequest(soapWithdrawAction), soapEndpointUrl);
当我尝试打印我得到的soapResponse 时,问题一开始就发布了 xml。
有什么方法可以实现吗?
【问题讨论】: