I’m working with a wsdl file, and learning quite a lot from the whole process.
I’m instantiating the SoapClient:
$webservice = new SoapClient("mainwsdl.wsdl");
var_dump($webservice->AccountsGetXML());
Below is the response, and I’m still a little new with parsing data.
object(stdClass)#2 (3) {
["AccountsGetXMLResult"]=>
object(stdClass)#3 (1) {
["any"]=>
string(391) "<AccountsWSDS xmlns=""><ERRORS><ERROR_ID>1</ERROR_ID><TABLE_NAME>Accounts</TABLE_NAME><TABLE_ID>NoID</TABLE_ID><ROW_ID>-1</ROW_ID><COLUMN_ID>EXCEPTION</COLUMN_ID><ERROR_TYPE>E</ERROR_TYPE><ERROR_CODE>0</ERROR_CODE><ERROR_TEXT>Error connecting to database - please contact ABC Customer Services. Msg: Object reference not set to an instance of an object.</ERROR_TEXT></ERRORS></AccountsWSDS>"
}
["rowCount"]=>
NULL
["pageCount"]=>
NULL
}
I haven’t played with object(stdClass) responses before. Or if I have I’ve been oblivious to it.
I figure I need to parse [“AccountsGetXMLResult”] for specific information, but also [“rowCount”] and [“pageCount”].
I’m confused what the #2 (3) is all about.
Anyway, here’s my attempt at parsing the data. I started with the AccountsGetXMLResult:
echo $webservice->AccountsGetXMLResult;
Here’s what I got back.
PHP Notice: Undefined property: SoapClient::$AccountsGetXMLResult in /apache/test.php on line 23
So clearly I’m in need of help with dissecting responses.
$webservice->AccountsGetXML()returns an object of typestdClasswith the properties you see in the var dump.stdClassis just an “empty placeholder class” without any predefined properties or methods of its own. To access the properties you see, work on the return value of$webservice->AccountsGetXML():This also works like this: