[dev] Anyone ever used the XML_RPC feature..??
René Lund Jensen
lundeman@tbkol.dk
Tue Oct 22 18:34:16 2002
Quoting Jan Schneider <jan@horde.org>:
| > Yes, the rpc class hasn't been updated after the latest changes in the
| > registry. I'll see if I can fix it in the next days.
|
| Hmm. Do we have to pre-register all the methods we're going to handle? If
| not, I can clean this up nicely; if so, it's kind of icky...
|
Well I rewrote the contructor for RPC.php to:
function RPC()
{
$this->server = xmlrpc_server_create();
foreach ($GLOBALS['registry']->registry as $api => $app) {
include_once $GLOBALS['registry']->getParam('fileroot', $app) .
'/lib/api.php';
}
if (isset($_services)){
foreach($_services as $service => $args){
xmlrpc_server_register_method($this->server, "$api.$service",
array('RPC', '_dispatcher'));
}
}
}
I also changed the _dispatcher method in RPC.php to read:
function _dispatcher($method, $params, $data)
{
$method = str_replace('.', '/', $method);
if (!$GLOBALS['registry']->hasMethod($method)) {
return sprintf(_("Method '%s' is not defined"), $method);
}
return $GLOBALS['registry']->call($method, $params);
}
Basiclly just switched from using "global $registry;" to use $GLOBALS,
but it did not change the next thing.
The call to hasMethod in the registry (using either $registry og
$GLOBALS['registry'])
returns false. So i started to debug that method.
I ended up totally confused. In the method "hasMethod" there is this check
if (!isset($this->_apiCache[$app]))
apiCache is not set, so the api.php file is included.
BUT after this, the $_services array is set, but has a count of (0).
All this is only when using XML_RPC, if I use $registry->callByPackage()
somewhere in my code
the "hasMethod"-method is also called, and here it behaves as expected.
(includes the file, and $_services has the right count).
Anyone has a clue here..??
Could it be that I commented out the authenticationpart of rpc.php ?
(for some reason it would not authenticate me, even though i know for sure
that the username and password can logon to horde(via imp), on the very same
installation that i call via RPC.
What I am doing is writing my own module for horde, and calling the RPC from
my own module.
I am doing this right now to test the RPC, I know that I could as well use
$registry->callByPackage().
René Jensen
lundeman@tbkol.dk