Zend_XmlRpc_Client_FaultException' with message 'Calling parameters do not match signature

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Zend_XmlRpc_Client_FaultException' with message 'Calling parameters do not match signature

anz_nabble
Hi,

I apologize for re posting this topic, but i think, re posting this topic in this category, would help me much , than posting in any other categories.

I am trying to implement a webservice using Zend XML RPC to update one
of my database tables for my domain smileeholidays.com. I am running
the client from another domain http://abudhabi.fundook.com.
When I run the client, I got error as

An exception occurred: Calling parameters do not match signature
Last Request: email.siteVisit44814
Last REsponse:

I had written the client part as c Controller and action. It is
provided below.

function responseAction()
    {

                Zend_Loader::loadClass('Zend_XmlRpc_Client');
                $response_id = $this->_request->getParam
('response_id');
                try {

                        $client = new Zend_XmlRpc_Client('http://
smileeholidays.com/Fundook/xmlrpc');
                        $result = $client->call('email.siteVisit',
$response_id);

                } catch (Zend_XmlRpc_Client_FaultException $e) {
    echo "An exception occurred: " . $e->getMessage() . "\n\n";
                }
                echo "<br/>Last Request: ", $client->getLastRequest()-
>__toString();

                echo "<br/>Last REsponse: ", $client->getLastResponse
()->__toString();

        }

and I on the server side, on the root dir, i had created a folder
called xmlrpc an inside of that, I had placed four files

1) .htaccess
2) index.php  which is exactly as

<?php
        include 'Bootstrap.php';

        set_include_path('.' . PATH_SEPARATOR . '../library/'
                 . PATH_SEPARATOR . '../application/models'
                 . PATH_SEPARATOR . get_include_path());
        include "Zend/Loader.php";
        Zend_Loader::loadClass('Zend_XmlRpc_Server');
        Zend_Loader::loadClass('Zend_Server_Abstract');

        $bootstrap = new Bootstrap('general');
        $bootstrap->runXmlRpc();
?>

3) Bootstrap.php    which looks like

<?
class Bootstrap
{
        public function __construct($deploymentEnvironment)
        {
        // Set up any configuration settings here
        }
        public function runXmlRpc()
        {

                        $server = new Zend_XmlRpc_Server();
                        require_once 'Emails.php';
                        $server->setClass('Emails','email');
                        $response = $server->handle();
                        $response->setEncoding('UTF-8');
                        header('Content-Type: text/xml;
charset=UTF-8');
                        echo $response;

        }
}

?>

and

4) <?php

        class Emails
        {

                /**
     * Echo back a integer
     *
     * @param integer $response_id
     * @return integer
     */
                public function siteVisit($response_id)
                {
                        $con = mysql_connect
('serverIp','uname','passwd');

                        if(!$con)
                        {
                                echo "Error - cannot connect to host";
                                exit;
                        }
                        $db =mysql_select_db('dbname',$con);
                        if(!$db)
                        {
                                echo "Error - cannot connect to
database";
                                exit;
                        }

                        $sql = "UPDATE emails  SET `ads_added`=2 WHERE
id =".$response_id;
                        mysql_query($sql);
                        return $response_id;

                }

        }
?>

when I removed the try catch blocks from the client, I got the output
as follows

Fatal error: Uncaught exception 'Zend_XmlRpc_Client_FaultException'
with message 'Calling parameters do not match signature' in /hsphere/
local/home/c244574/fundook.com/library/Zend/XmlRpc/Client.php:348
Stack trace: #0 /hsphere/local/home/c244574/fundook.com/application/
modules/default/controllers/ConfirmController.php(40):
Zend_XmlRpc_Client->call('email.siteVisit', '44814') #1 /hsphere/local/
home/c244574/fundook.com/library/Zend/Controller/Action.php(503):
ConfirmController->responseAction() #2 /hsphere/local/home/c244574/
fundook.com/library/Zend/Controller/Dispatcher/Standard.php(285):
Zend_Controller_Action->dispatch('responseAction') #3 /hsphere/local/
home/c244574/fundook.com/library/Zend/Controller/Front.php(934):
Zend_Controller_Dispatcher_Standard->dispatch(Object
(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http))
#4 /hsphere/local/home/c244574/fundook.com/index.php(264):
Zend_Controller_Front->dispatch() #5 {main} thrown in /hsphere/local/
home/c244574/fundook.com/library/Zend/XmlRpc/Client.php on line 348

Anyone know what is wrong in my code.  Please help ASAP...

Regards
Anz
Reply | Threaded
Open this post in threaded view
|

Re: Zend_XmlRpc_Client_FaultException' with message 'Calling parameters do not match signature

anz_nabble
Fortunately, I had fixed the problem by making some small changes to the client part.

I had modified the client-side as follows

function responseAction()
    {
    global $db,$site_domain_location;
                $filter = new Zend_Filter_StripTags();
                $response_id = (int) $this->_request->getParam('response_id');
                try {
                        $client = new Zend_XmlRpc_Client('http://smileeholidays.com/Fundook/xmlrpc');
                        $result = $client->call('email.siteVisit', array($response_id));
                } catch (Zend_XmlRpc_Client_FaultException $e) {
    echo "An exception occurred: " . $e->getMessage() . "\n\n";
                }
 
        }

One important thing to notice, is that, when the sever function is called using parameters, always try to pass it using an array just like
$result = $client->call('email.siteVisit', array($response_id));  

Here the parameter $response_id always holds an integer value,
ie:    $response_id = (int) $this->_request->getParam('response_id');

So in the Emails.php, it is very important to place the doc-block as follows

      /**
     * Echo back a integer
     *
     * @param integer $response_id
     * @return integer
     */


(My Special thanks to  Mr. Matthew Weier O'Phinney)
http://www.mail-archive.com/fw-general@lists.zend.com/msg06047.html

Hope, this may be helpful to someone... Cheers

Regards
Anz