RE: [PEAR] PHP5 and XML-RPC
| From: | Justin Philpott | Date: | Mon, 02 Aug 2004 17:03:55 +0000 |
| Subject: | RE: [PEAR] PHP5 and XML-RPC | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-13937@lists.php.net to get a copy of this message | ||
Hi Jough,
By looking at line 1083 I can see that whatever is getting passed to
XML_RPC_decode() is not a valid XML_RPC_Value object
By looking at the code, if a fault were to occur, it still tries to
printout the value of the result. Reading the PEAR XML_RPC API docs says
this:
"If the response's faultCode is non-zero then the value returned by this
method should not be used (it may not even be an object)" ...
I think this may be the problem, so get it to print the faultCode and
faultString but like this instead:
if($result->faultCode()) {
// we have an error
echo "Error\n"; // print the code and string here
} else {
// no error, you should get some decoded value out
print XML_RPC_decode($result->value());
}
// always use {} with control structures, if you don't it will bite you
in the ass eventually...
// and remember to turn on debugging to see what's going on...
hope this helps,
Justin
-----Original Message-----
From: Jough P [mailto:jough@wiretapped.us]
Sent: 31 July 2004 19:00
To: pear-general@lists.php.net
Subject: [PEAR] PHP5 and XML-RPC
Greetings all, I'm copying code straight out of _Advanced PHP
Programming_ and am getting the following error on a Linux/Apache/PHP5
box:
Fatal error: Call to a member function kindOf() on a non-object in
/usr/local/lib/php/XML/RPC.php on line 1083
I'm wondering if the pear XML-RPC class has any issues with PHP 5.
But, I'm just learning how to use XML-RPC and could very well be doing
something stupid. ANY help at all would be greatly appreciated.
Here is the code:
CLIENT:
<?php
require_once 'XML/RPC.php';
$client = new XML_RPC_Client('/xmlrpc.php', 'localhost');
$msg = new XML_RPC_Message('system.load');
$result = $client->send($msg);
if($result->faultCode())
echo "Error\n";
print XML_RPC_decode($result->value());
?>
SERVER:
<?php
require_once 'XML/RPC/Server.php';
function system_load()
{
$uptime =
uptime;
if(preg_match("/load average: ([\d.]+/", $uptime, $matches))
{
return new XML_RPC_Response(new XML_RPC_Value($matches[1],
'string'));
}
}
$dispatches = array('system.load' => array('function' =>
'system_uptime'));
new XML_RPC_Server($dispatches, 1);
?>
--
PEAR General Mailing List (http://pear.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php