Calling methods in returned SOAP objects
| From: | Marcus Bointon | Date: | Wed, 27 Jul 2005 15:56:04 +0000 |
| Subject: | Calling methods in returned SOAP objects | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-219430@lists.php.net to get a copy of this message | ||
I'm successfully calling SOAP functions via a WSDL interface using PHP5, but sometimes the functions return things that are complex objects with methods as well as attributes. For example, the interface I'm using has a query function which returns an array, but it also has a function called IsDone() which can be called to find out if this is the last page of results (it returns records in batches).
It goes like this:
<?php
require_once 'MyClient.class.php';
$mc = new MyClient();
$mc->dologin('id', 'pass');
try {
$res = $mc->query(array('queryString' => 'select Field from Table'));
$alldone = $res->isDone();
} catch (SoapFault $f) {
print 'Caught Exception: '. $f->faultstring. "\n";
var_dump($mc);
}
?>
You can see that $res is the result returned from the query, and it is presented as a stdClass object with results stored in an array property. However, when I try to call $res->IsDone(), it fails to work:
PHP Fatal error: Call to undefined method stdClass::isDone()
I have some example code in Java for the same WSDL that makes it look very simple:
...
queryResult = binding.query("select Field from Table");
if (queryResult.isDone()) {
...
How on earth do I do that in PHP? I don't think that creating PHP classes and using classmap will help (it just moves the problem), at least partly because this is a dynamic WSDL that is subject to change.
Marcus
--
Marcus Bointon
Synchromedia Limited: Putting you in the picture
marcus@synchromedia.co.uk | http://www.synchromedia.co.uk