【发布时间】:2011-12-28 00:08:31
【问题描述】:
如何从这个 SOAP 回复信封中读取 error_code?我的 PHP 版本是:5.2.0。
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
<soap:Body>
<Response xmlns="http://xxx.gateway.xxx.abcd.com">
<return>
<transaction_id>1234567</transaction_id>
<error_code>109</error_code>
</return>
</Response>
</soap:Body>
</soap:Envelope>
我只需要读取error_code标签的值。这里的值是:109
我正在使用 nusoap。我使用了以下代码但无法正常工作:
$response=htmlspecialchars($client->response, ENT_QUOTES);
$xml = simplexml_load_string($response);
$ns = $xml->getNamespaces(true);
$soap = $xml->children($ns['soap']);
$error_code = $soap->body->children($ns['error_code']);
【问题讨论】: