0

All,

I am trying to access element ebl:RequesterCredentials in a SOAP response but having no success so far. I am using PHP SimpleXML. The issue for me at least is registering the ebl namespace - All I am getting in the response is this:

xmlns=”urn:ebay:apis:eBLBaseComponents”

I Tried this:

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

}

The element is nested as such:

soapenv:Envelope -> soapenv:Header -> ebl:RequesterCredentials -> ebl:NotificationSignature

<soapenv:Envelope 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:Header> <ebl:RequesterCredentials xmlns:ns="urn:ebay:apis:eBLBaseComponents" xmlns:ebl="urn:ebay:apis:eBLBaseComponents" soapenv:mustUnderstand="0"> <ebl:NotificationSignature xmlns:ebl="urn:ebay:apis:eBLBaseComponents">9hJXr9QTtck33I/4wg135A==</ebl:NotificationSignature> </ebl:RequesterCredentials> </soapenv:Header> <soapenv:Body> <GetMemberMessagesResponse xmlns="urn:ebay:apis:eBLBaseComponents"> <Message>FOO</Message> <Timestamp>2007-09-14T17:07:41.984Z</Timestamp> </GetMemberMessagesResponse> </soapenv:Body> </soapenv:Envelope>

Any ideas on how to access this element?

Slinky
  • 5,662
  • 14
  • 76
  • 130

1 Answers1

0

After several different attempts to access the element value, this got me what I needed, although it's probably way too verbose.

$xml = simplexml_load_string(...);
$sig = (string) $xml->children('http://schemas.xmlsoap.org/soap/envelope/')->children('urn:ebay:apis:eBLBaseComponents')->RequesterCredentials->NotificationSignature;
Slinky
  • 5,662
  • 14
  • 76
  • 130