-- Nilesh Ashra <[EMAIL PROTECTED]> wrote
(on Tuesday, 24 July 2007, 05:46 PM +0100):
> Hi all,
>
> I've created a Zend_XmlRpc_Server, like so:
>
> require_once "Zend/XmlRpc/Server.php";
> function echoTest()
> {
> return "Hello, world";
> }
> $server = new Zend_XmlRpc_Server();
> $server->addFunction("echoTest");
> echo $server->handle();
>
> Calling the "echoTest" method using Zend_XmlRpc_Client works fine like this:
>
> require_once 'Zend/XmlRpc/Client.php';
> $client = new Zend_XmlRpc_Client('http://myhostname/index.php');
> print_r($client->call('echoTest'));
>
> This definitely works, I get "Hello, world" in the browser.
>
> However, if I add a parameter to the echoTest method like so:
>
> function echoTest($textToEcho)
> {
> return "You said: " . $textToEcho;
> }
>
> and call it using the client class like this this:
>
> require_once 'Zend/XmlRpc/Client.php';
> $client = new Zend_XmlRpc_Client('http://myhostname/index.php');
> print_r($client->call('echoTest', array("HELLO WORLD!")));
>
> I get the following exception:
>
> Fatal error: Uncaught exception 'Zend_XmlRpc_Client_FaultException' with
> message 'Calling parameters do not match signature' in /usr/local/include/php/
> php-5.2.3/zend_framework_co/library/Zend/XmlRpc/Client.php:261 Stack trace: #0
> /private/var/www/VirtualHosts/myhostname/public/phpclient.php(5):
> Zend_XmlRpc_Client->call('echoTest', Array) #1 {main} thrown in /usr/local/
> include/php/php-5.2.3/zend_framework_co/library/Zend/XmlRpc/Client.php on line
> 261
>
> It seems adding any parameter to a method or function causes this error.
> Functions/methods with no parameters always work.
>
> I've been trying to get it to work for hours, and consulted the docs (even
> copied examples from the docs) but I always get this error. I'm using php
> 5.2.3
> and apache 2, but have also tried it on a different server with php 5.1.6.
>
> I have tried using Zend Framework from svn trunk, but that doesn't fix it
> either.
>
> Am I missing something very fundamental?
Yes. You need to have docblocks in place:
/**
* Echo back a string
*
* @param string $textToEcho
* @return string
*/
function echoTest($textToEcho)
{
return "You said: " . $textToEcho;
}
The docblocks are used to provide type hinting so that the XmlRpc server
knows what variable types are allowed for a given parameter -- this is
both as a security measure as well as to ensure that method signatures
are properly generated.
--
Matthew Weier O'Phinney
PHP Developer | [EMAIL PROTECTED]
Zend - The PHP Company | http://www.zend.com/