I was not able to find same problem, for that reason I decided to open new.
I’ve stuck with an issue below.
The target is to show xml attributes values on UI using soap message.
PHP code looks like:
$client = new SoapClient("https://domain.com/xml/listener.asmx?WSDL");
$results = $client->ProductDescription(array('Username' => "anyuser", 'Password' => "anypassword", 'code' => "1108324"));
print_r($results);
As a result i get following message
stdClass Object ( [ProductDescriptionResult] => stdClass Object ( [any] => Imagehttp://catalog2.elkogroup.com/pictures/prDesc/large/1108324_425_0_425NULL.jpgDescription<h1 class="tagline"><span style="font-size: small">Quality surround audio for music, movies and games</span></h1> <p> Sound Blaster 5.1 VX is the absolute choice for those looking for better quality audio solutions basic motherboard audio can not deliver.</p>Vendor Homepagehttp://en.europe.creative.com/products/productarchive.asp?category=1&subcategory=873&product=17510&nav=Description2CREATIVE 5.1 VX (SB1071) OEMAudio-InInput/Output connectors1Audio-OutInput/Output connectors1MicrophoneInput/Output connectors1Included AccessoriesQuick start Guide; User Guide (on CD); Installation CDUnit Brutto Volumecubm0.001555Unit Net Weightkg0.13Unit Gross Weightkg0.157 ) )
The xml I get from soap ui using same request has different structure
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<ProductDescriptionResponse xmlns="https://ecom.elko.lv/xml">
<ProductDescriptionResult>
<NewDataSet xmlns="">
<Product>
<Criteria>Image</Criteria>
<Value>http://test/</Value>
</Product>
...
...
</NewDataSet>
</ProductDescriptionResult>
</ProductDescriptionResponse>
</soap:Body>
</soap:Envelope>
I was trying to read Criteria and Value argument values using different approaches, for example
a)
foreach($Envelope->Body->ProductDescriptionResponse->ProductDescriptionResult->NewDataSet->Product as $p)
{
echo $p->Criteria."<br>";
echo $p->Value."<br>";
}
Error message was “Undefined variable: Envelope…”
b)
foreach ($results->xpath('//soap:Envelope[1]/soap:Body[1]/ProductDescriptionResponse[1]/ProductDescriptionResult[1]/NewDataSet[1]/Product/*') as $item)
{ print_r($item);}
Error message was Call to undefined method stdClass::xpath()
c)
Also tried to register namespace
$xml = simplexml_load_string($results);
$xml->registerXPathNamespace('envoy', 'https://ecom.elko.lv/xml');
…
But it says me that simplexml_load_string() expects parameter 1 to be string
etc…
Could you please help to figure out?
Take it from the response element (
ProductDescriptionResult), which is what theSOAPClientwould give you:Keep in mind you don’t have XML here anymore, the
SOAPClientconverted it to a nice tree of objects for you already. It could be that at any point the above trail doesn’t exist (I just guessed it based on the XML), in that case, just do avar_dumpfromget_object_varsto see what’s in the current node. Oh, and don’t look at the HTML output in a browser, view the source, a lot of<and>s in your debug output can ‘hide’ content if you look at is as HTML.edit: this works here