* IXR_IntrospectionServer
class IXR_IntrospectionServer extends IXR_Server
$this->setCapabilities();
$this->capabilities['introspection'] = array(
'specUrl' => 'http://xmlrpc.usefulinc.com/doc/reserved.html',
'system.methodSignature',
array('array', 'string'),
'Returns an array describing the return type and required parameters of a method'
'system.getCapabilities',
'Returns a struct describing the XML-RPC specifications supported by this server'
'Returns an array of available methods on this server'
array('string', 'string'),
'Returns a documentation string for the specified method'
public function IXR_IntrospectionServer() {
function addCallback($method, $callback, $args, $help)
$this->callbacks[$method] = $callback;
$this->signatures[$method] = $args;
$this->help[$method] = $help;
function call($methodname, $args)
// Make sure it's in an array
if ($args && !is_array($args)) {
// Over-rides default call method, adds signature check
if (!$this->hasMethod($methodname)) {
return new IXR_Error(-32601, 'server error. requested method "'.$this->message->methodName.'" not specified.');
$method = $this->callbacks[$methodname];
$signature = $this->signatures[$methodname];
$returnType = array_shift($signature);
// Check the number of arguments
if (count($args) != count($signature)) {
return new IXR_Error(-32602, 'server error. wrong number of method parameters');
// Check the argument types
for ($i = 0, $j = count($args); $i < $j; $i++) {
$arg = array_shift($args);
$type = array_shift($signature);
if (is_array($arg) || !is_int($arg)) {
if ($arg !== false && $arg !== true) {
if (!is_a($arg, 'IXR_Date')) {
return new IXR_Error(-32602, 'server error. invalid method parameters');
// It passed the test - run the "real" method call
return parent::call($methodname, $argsbackup);
function methodSignature($method)
if (!$this->hasMethod($method)) {
return new IXR_Error(-32601, 'server error. requested method "'.$method.'" not specified.');
// We should be returning an array of types
$types = $this->signatures[$method];
foreach ($types as $type) {
$return[] = new IXR_Date(time());
$return[] = new IXR_Base64('base64');
$return[] = array('array');
$return[] = array('struct' => 'struct');
function methodHelp($method)
return $this->help[$method];