PHP   发布时间:2022-04-09  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了如何通过PHP读取SOAP回复包络大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
如何从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>
@H_874_3@我只需要读取error_code tag的值.其值为:109

@H_874_3@我正在使用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']);
<?PHP 

$String = <<<XML
<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>
XML;

$xml = new SimpleXMLElement($String); 
$xml->registerXPathNamespace("soap","http://www.w3.org/2003/05/soap-envelope");
$body = $xml->xpath("//soap:Body");
$error_code = (String)$body[0]->Response->return->error_code;
print_r($error_codE); 
?>
@H_874_3@要么

$xml = simplexml_load_String($String); 
 $error_code = (String)$xml->children('soap',truE)
                            ->Body
                            ->children()
                            ->Response
                            ->return
                            ->error_code;

大佬总结

以上是大佬教程为你收集整理的如何通过PHP读取SOAP回复包络全部内容,希望文章能够帮你解决如何通过PHP读取SOAP回复包络所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。