To not post so "much" code inside this mail I added some attachments.

Attachments:
- xmlrpc_server.php
- xmlrpc_client.php
- result.txt

The server gets the correct request (xml) but I don´t know why this request cannot be handled.

(btw.: what is i4?)

-- Jan


-- Jan Pieper <[EMAIL PROTECTED]> wrote
(on Thursday, 01 March 2007, 09:22 PM +0100):
My class looks like:

class Flabben_XmlRpc_Server
{
    /**
     * add entry to database and return its id
     *
     * @access public
     * @param  integer $iUserId
     * @param  string $sTitle
     * @param  string $sContent
     * @return integer
     */
    public function addEntry($iUserId, $sTitle, $sContent)
    {
        return 1;
    }
}

That looks good -- what is the data being sent to it that's causing the
error? I'm wondering if one or more items were not the right type?
Zend_XmlRpc_Server uses Zend_XmlRpc_Value to 'guess' the type; it's
possible that there's an issue in there. Give as much detail as you can,
and I'll try and track it down.


    -- Jan Pieper <[EMAIL PROTECTED]> wrote
    (on Thursday, 01 March 2007, 07:23 PM +0100):


        The result I get ist:

        <?xml version="1.0" encoding="UTF-8"?>
        
<methodResponse><params><param><value><string/></value></param></params></
        methodResponse>
        Zend_XmlRpc_Client_FaultException caught: Calling parameters do not 
match
        signature

        I can´t find my mistake...



    Read the docs. :-)

    The Zend server classes use the Reflection API to determine the
    dispatchable prototypes -- and determines the number and types for the
    method parameters and return value. When an incoming request happens, it
    checks the calling parameters against the registered prototypes. So, if
    the calling parameters do not match, you get that message.

    The fix? Make sure that you do your docblocks thoroughly:

        /**
         * do something with a table
         *
         * @param string $table
         * @param int $id
         * @param struct $values (Struct denotes an assoc array)
         * @return boolean
         */
        public function doSomething($table, $id, $values);

    Just make sure you use valid xml-rpc types for the typehints -- struct
    for associative arrays, int(eger), bool(ean), float/double, array,
    string, base64, date.iso9601 (dates).

    Also, you *can* OR the types if more than one type is possible:

        /**
         * Do something
         *
         * @param string $table
         * @param int|string $id
         * @param string|struct $values
         * @return boolean
         */

    (The above will have 4 valid prototypes.)



            -- Werner <[EMAIL PROTECTED]> wrote
            (on Thursday, 01 March 2007, 06:42 PM +0200):


                I also want to start playing around with it for an upcoming 
project.

                Would you mind posting the skeleton on the list? (to me, the 
list also
                serves as a repository (and archive) of code snippets, etc.

                I love searching for keywords and topics in the list with my 
mail
                client, it has proven to be a useful resource to me many times 
before.
                Therefore, I would like to ask you to please put as much 
example code in
                the list as possible, since you are knowledgeable and it 
provides a
                general answer (or starting point) to list-subscribers.

                Thank you for your time and effort,
                Werner

                Matthew Weier O'Phinney wrote:


                    I have. Contact me off-list, and I'll provide a skeleton 
for you.



            Okay, it's below.

            There are some points where you'll need to modify it (require 
service
            classes and attach them to the server, specify path to a cache file,
            specify exception classes that may return XML-RPC faults, etc.).
            Additionally, you may want to add some logging functionality 
surrounding
            the handle() call -- log the request and response, for instance, or 
just
            log request/response when fault responses occur.

            =============================================================
            <?php
            // Turn of error reporting; mucks with XML responses
            ini_set('display_errors', false);

            /** Zend_Controller_Action */
            require_once 'Zend/Controller/Action.php';

            /** Zend_XmlRpc_Server */
            require_once 'Zend/XmlRpc/Server.php';

            /** Zend_XmlRpc_Server_Cache */
            require_once 'Zend/XmlRpc/Server/Cache.php';

            /** Zend_XmlRpc_Server_Fault */
            require_once 'Zend/XmlRpc/Server/Fault.php';

            /**
             * Also load your service classes here:
             * require_once 'Services/Foo.php'; // etc.
             */

            /**
             * XMLRPC Controller: dispatch XMLRPC requests
             *
             * URI route is: /xml-rpc
             *
             * Any additional URI components will be ignored.
             *
             * @uses Zend_Controller_Action
             * @uses Zend_XmlRpc_Server
             */
            class XmlRpcController extends Zend_Controller_Action
            {
                /**
                 * Override and/or set this to specify a server cache file
                 * @var string
                 */
                public $cacheFile;

                /**
                 * Array of exception classes that can be reported as XML-RPC 
faults.
                 * Override or set this value.
                 * @var array
                 */
                public $validExceptionClasses = array();

                /**
                 * Sets the cache file to a sane default if not set
                 *
                 * @return void
                 */
                public function init()
                {
                    if (null === $this->cacheFile) {
                        $this->cacheFile = dirname(__FILE__) . 
'/../cache/xmlrpc.cache';
                    }
                }

                /**
                 * Index action: dispatch xmlrpc server
                 *
                 * @return void
                 */
                public function indexAction()
                {
                    $this->dispatchXmlrpc();
                }

                /**
                 * Forward to indexAction()
                 *
                 * @param  string $method
                 * @param  array $args
                 * @return void
                 */
                public function __call($method, $args)
                {
                    return $this->_forward('index');
                }

                /**
                 * Dispatch XMLRPC server
                 *
                 * @access public
                 * @return void
                 */
                public function dispatchXmlrpc()
                {
                    $server = new Zend_XmlRpc_Server();

                    // Ortus_Exceptions will be returned as fault responses
                    foreach ($this->validExceptionClasses as $class) {
                        Zend_XmlRpc_Server_Fault::attachFaultException($class);
                    }

                    if (!Zend_XmlRpc_Server_Cache::get($this->cacheFile, 
$server)) {
                        /**
                         * Attach XML-RPC classes, with optional namespaces. 
Example:
                         * $server->setClass('Service_Foo', 'foo');
                         * $server->setClass('Model_Bar', 'bar');
                         */

                        Zend_XmlRpc_Server_Cache::save($this->cacheFile, 
$server);
                    }

                    // Dispatch request...
                    $response = $server->handle();
                    $response->setEncoding('ISO-8859-1');
                    header('Content-Type: text/xml; charset=ISO-8859-1');
                    echo $response->saveXml();
                }
            }














----- REQUEST ------------------------------------------------------------------

<?xml version="1.0" encoding="UTF-8"?>
<methodCall><methodName>flabben.addEntry</methodName><params><param><value><int>1</int></value></param><param><value><string>Test</string></value></param><param><value><string>Huhu</string></value></param></params></methodCall>

----- RESPONSE -----------------------------------------------------------------

<?xml version="1.0" encoding="UTF-8"?>
<methodResponse><params><param><value><string/></value></param></params></methodResponse>

Attachment: xmlrpc_server.php
Description: application/php

Attachment: xmlrpc_client.php
Description: application/php

Reply via email to