-- Waigani <[EMAIL PROTECTED]> wrote
(on Friday, 02 November 2007, 02:37 AM -0700):
> I'm trying a simple 'hello world' test of xmlrpc but keep getting:
>
> "Uncaught exception 'Zend_XmlRpc_Client_FaultException' with message 'Failed
> to parse response'"
These are almost always a result of having display_errors on on the
server. Make sure the script where you server the XML-RPC server has
display_errors turned off.
> So I've got:
> 1. a function in a class
>
> /**
> * Say Hello
> *
> * @return string
> */
> function hello(){
> return 'Hello World';
> }
So far, so good -- you've defined the php docblock correctly, which is
the other typical pitfall for the various server classes.
> 2. A server in an action:
>
> function xmlrpcAction(){
>
> $server = new Zend_XmlRpc_Server();
> $server->setClass('Hs_Profile', 'profile');
> echo $server->handle();
> echo $server->getRequest();
You should never return anything other than the XML-RPC response; doing
otherwise will result in invalid XML, which means the client will not be
able to parse it.
> }
>
> 3. A client call in a view:
>
> $client = new
> Zend_XmlRpc_Client('http://technology.otago.ac.nz/Profile/index/xmlrpc');
> echo $client->call('profile.hello');
>
> I've read through the list but can't find an answer. I've tried with error
> reporting on and off, and, as you can see, I've also tried getRequest().
On the server side, try logging the request and response to a file to
see first what you're receiving (you want to be sure the XML received is
valid) and what you're returning (you need to know if you're always
returning a fault exception, or if the XML is indeed valid). Easy way to
do that:
$response = $server->handle();
$request = $server->getRequest();
$log = new Zend_Log(new Zend_Log_Writer_Stream('/tmp/xmlrpc.log'));
$log->info("Request:\n$request");
$log->info("Response:\n$response");
echo $response;
If you see that you're always getting a fault response, you should check
your application code (i.e., the class(es) you've attached to the
server) to see if there are any exceptions being thrown -- perhaps in
the constructor. Finally, it's entirely possible that the application
class isn't being loaded in the first place, which would lead to *no*
response whatsoever; make sure your class is being loaded either via
__autoload or a require_once call.
Hopefully with that information, you should be able to debug a bit
further.
--
Matthew Weier O'Phinney
PHP Developer | [EMAIL PROTECTED]
Zend - The PHP Company | http://www.zend.com/