Jayyrus
Jayyrus

Reputation: 13051

SoapClient parse response

i need to parse that response take from:

$client->__getLastResponse();

uuid:9e0096e0-de0f-11e1-8035-e656d1754971

http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous 0 ContentType text/xml 1 
Result 200 2 XMLDocumentOut <?xml version="1.0" encoding="utf-8" ?> 
<DtsAgencyLoginResponse xmlns="DTS" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="DTS file:///R:/xsd/DtsAgencyLoginMessage_01.xsd">
<SessionInfo><SessionID>178827</SessionID><Profile>A</Profile><Language>ENG</Language>
<Version>1</Version>
</SessionInfo><AdvisoryInfo/></DtsAgencyLoginResponse>

How can i parse it to take SessionID ? Thanks!

EDIT:

the result of method $client->method($parameter) is:

stdClass Object ( [result] => [ttOut] => stdClass Object ( [ttOutRow] => Array ( [0] => stdClass Object ( [ParPos] => 0 [ParNam] => ContentType [ParVal] => text/xml ) [1] => stdClass Object ( [ParPos] => 1 [ParNam] => Result [ParVal] => 200 ) [2] => stdClass Object ( [ParPos] => 2 [ParNam] => XMLDocumentOut [ParVal] => 178880AENG1 ) ) ) [opcErrorMessage] => )

Upvotes: 1

Views: 9618

Answers (1)

softius
softius

Reputation: 166

When invoking SOAP methods via PHP5 SOAPClient you always get the response back. That is to say it may be not necessary to call __getLastResponse() to retrieve SessionID value. Have a look at the following:

$response = $client->myMethod();
$sessionID = $response->SessionInfo->SessionID;

Also http://www.php.net/manual/en/soapclient.soapcall.php

Upvotes: 3

Related Questions