【问题标题】:How to drill into SOAP Namespaces with SimpleXML & PHP [duplicate]如何使用 SimpleXML 和 PHP 深入研究 SOAP 命名空间 [重复]
【发布时间】:2011-11-21 21:47:12
【问题描述】:

全部,

我正在尝试访问 SOAP 响应中的元素 ebl:RequesterCredentials,但到目前为止没有成功。我正在使用 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:Envelope -> soapenv:Header -> ebl:RequesterCredentials -> ebl:NotificationSignature

9hJXr9QTtck33I/4wg135A==标题> FOO2007-09-14T17:07:41.984Z时间戳> 正文> 信封>

关于如何访问此元素的任何想法?

【问题讨论】:

  • $h = $xml->xpath('/soapenv:Header/ebl:RequesterCredentials');

标签: php soap simplexml


【解决方案1】:

在多次尝试访问元素值之后,这得到了我需要的东西,尽管它可能太冗长了。

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

【讨论】:

    猜你喜欢
    • 2014-09-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-06-20
    • 2018-07-05
    • 1970-01-01
    • 1970-01-01
    • 2012-01-06
    相关资源
    最近更新 更多