如何使用SimpleXML和PHP深入到SOAP命名空间 [英] How to drill into SOAP Namespaces with SimpleXML & PHP

查看:0
本文介绍了如何使用SimpleXML和PHP深入到SOAP命名空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

全部,

我正在尝试访问SOAP响应中的元素ebl:Requester Credentials,但到目前为止还没有成功。我使用的是PHP SimpleXML。至少对我来说,问题是注册EBL命名空间-我在响应中得到的唯一结果是:

xmlns="urn:ebay:apis:eBLBaseComponents"

我尝试过:

$r =     $xml->registerXPathNamespace("ebl","urn:ebay:apis:eBLBaseComponents");
foreach($xml->xpath('ebl:RequesterCredentials') as $e){
$sig = (string) $e->NotificationSignature;

}

该元素按如下方式嵌套:

soapenv:信封->soapenv:Header->ebl:Requester Credentials->ebl:NotificationSignature

<;soapenv:信封xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"xmlns:xsd="http://www.w3.org/2001/XMLSchema"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">; <;soapenv:标题>; <;ebl:Requester Credentials xmlns:ns="urn:eBay:apis:eBLBaseComponents"xmlns:ebl="urn:eBay:apis:eBLBaseComponents"soapenv:mashUnderstand="0">; <;eBL:通知签名xmlns:ebl="urn:ebay:apis:eBLBaseComponents">;9hJXr9QTtck33I/4wg135A==<;/ebl:NotificationSignature>; <;/ebl:申请人凭证>; <;/soapenv:页眉>; <;soapenv:Body>; <;GetMemberMessagesResponse xmlns="urn:eBay:API:eBLBaseComponents">; <;Message>;foo<;/Message>; <;Timestamp>;2007-09-14T17:07:41.984Z<;/Timestamp>; <;/GetMemberMessagesResponse>; <;/soapenv:Body>; <;/soapenv:信封>;

关于如何访问此元素有什么建议吗?

推荐答案

经过几次不同的访问元素值尝试后,我得到了所需的内容,尽管它可能太过冗长。

$xml = simplexml_load_string(...);
$sig = (string) $xml->children('http://schemas.xmlsoap.org/soap/envelope/')->children('urn:ebay:apis:eBLBaseComponents')->RequesterCredentials->NotificationSignature;

这篇关于如何使用SimpleXML和PHP深入到SOAP命名空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆