How to extract value using php soapclient [message #173756] |
Tue, 03 May 2011 08:49 |
ofuuzo
Messages: 1 Registered: May 2011
Karma: 0
|
Junior Member |
|
|
Hi,
I have just started learning to program with PHP SOAPclient. I have
the following xml file and I want to extract/get the value
rs-1304338811289-11595:
- <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/
envelope/">
- <soap:Body>
- <ns2:deliverMDRecordsResponse xmlns:ns2="http://
mdstore.data.dnetlib.eu/" xmlns:ns3="http://www.w3.org/2005/08/
addressing">
- <return>
<ns3:Address>http://129.70.212.20:8282/dnet-mdstore/
services/MDStoreResultSet</ns3:Address>
- <ns3:ReferenceParameters>
<ResourceIdentifier:ResourceIdentifier
xmlns:ResourceIdentifier="http://www.driver.org" xmlns:wsa="http://
www.w3.org/2005/08/addressing">rs-1304338811289-11595</ResourceIdentifier:ResourceIdentifier >
</ns3:ReferenceParameters>
-......
</return>
</ns2:deliverMDRecordsResponse>
</soap:Body>
</soap:Envelope>
My php script that is not working:
<?php
$source = 'resourceIdentifier.xml';
$xml = simplexml_load_string($source);
$xml->registerXPathNamespace('identifier', 'ns3');
foreach ($xml->xpath('//identifier:ResourceIdentifier') as $item)
{
print_r($item);
}
?>
I need help and thanks in advance.
- Ofuuzo
|
|
|
Re: How to extract value using php soapclient [message #173776 is a reply to message #173756] |
Wed, 04 May 2011 09:01 |
Jonathan Stein
Messages: 43 Registered: September 2010
Karma: 0
|
Member |
|
|
Den 03-05-2011 10:49, ofuuzo skrev:
> I have just started learning to program with PHP SOAPclient.
But your example doesn't use the SOAP client?
It looks like you somehow captured a SOAP response and tries to
interpret it manually.
The idea of the SOAP client is to forget about the SOAP protocol and
call a remote function (almost) as if it was a local function.
What you should get from the SOAP client is a PHP object, that you can
use directly. Basically you should do something like:
$client = new SoapClient('some.wsdl');
$result = $client->RemoteFunction($a, $b, $c, ...);
print_r($result);
The SOAP client is not the best documented part of PHP, but try to read
http://www.php.net/manual/en/book.soap.php and especially the client
part, if you haven't already been there.
Regards
Jonathan
|
|
|