PEAR XML_RPC Part 2

  • Posted by Mike Naberezny in PHP

    Regarding my earlier woes about XML-RPC functions in the global scope, upgrading to the latest stable version of XML_RPC has mostly alleviated the problem. This complaint was addressed in Bug 3363 and fixed in version 1.2.0RC7. Since this fix, the dispatch map can now utilize class functions, albeit only statically. In the dispmap, the functions may be declared one of two ways:

    'function' => 'myClass::rpcFunction'
    

    or

    'function' => array('myClass', 'rpcFunction')
    

    Allowing class functions to be mapped is a great improvement. I am now using a class for my XML-RPC API, with a class method to return the dispmap to be passed into XML_RPC_Server.

    The ability for XML_RPC_Server to call class functions has an additional benefit for PHP5 users, at least until something like XML_RPC2 becomes stable. In PHP5, the function get_class_methods() is now case sensitive, so introspection may be used to build the function declarations in the dispmap. However, this will still not be enough to generate the method signature or docstring. PHP5’s Reflection API can accomplish this, and it can even be used to get the docstring.