function xmlrpc_server_call in Drupal 5
Same name and namespace in other branches
- 4 includes/xmlrpcs.inc \xmlrpc_server_call()
- 6 includes/xmlrpcs.inc \xmlrpc_server_call()
- 7 includes/xmlrpcs.inc \xmlrpc_server_call()
Dispatch the request and any parameters to the appropriate handler.
Parameters
$xmlrpc_server:
$methodname: The external XML-RPC method name, e.g. 'system.methodHelp'
$args: Array containing any parameters that were sent along with the request.
2 calls to xmlrpc_server_call()
- xmlrpc_server in includes/
xmlrpcs.inc - The main entry point for XML-RPC requests.
- xmlrpc_server_multicall in includes/
xmlrpcs.inc
File
- includes/
xmlrpcs.inc, line 144
Code
function xmlrpc_server_call($xmlrpc_server, $methodname, $args) {
// Make sure parameters are in an array
if ($args && !is_array($args)) {
$args = array(
$args,
);
}
// Has this method been mapped to a Drupal function by us or by modules?
if (!isset($xmlrpc_server->callbacks[$methodname])) {
return xmlrpc_error(-32601, t('Server error. Requested method @methodname not specified.', array(
"@methodname" => $xmlrpc_server->message->methodname,
)));
}
$method = $xmlrpc_server->callbacks[$methodname];
$signature = $xmlrpc_server->signatures[$methodname];
// If the method has a signature, validate the request against the signature
if (is_array($signature)) {
$ok = TRUE;
$return_type = array_shift($signature);
// Check the number of arguments
if (count($args) != count($signature)) {
return xmlrpc_error(-32602, t('Server error. Wrong number of method parameters.'));
}
// Check the argument types
foreach ($signature as $key => $type) {
$arg = $args[$key];
switch ($type) {
case 'int':
case 'i4':
if (is_array($arg) || !is_int($arg)) {
$ok = FALSE;
}
break;
case 'base64':
case 'string':
if (!is_string($arg)) {
$ok = FALSE;
}
break;
case 'boolean':
if ($arg !== FALSE && $arg !== TRUE) {
$ok = FALSE;
}
break;
case 'float':
case 'double':
if (!is_float($arg)) {
$ok = FALSE;
}
break;
case 'date':
case 'dateTime.iso8601':
if (!$arg->is_date) {
$ok = FALSE;
}
break;
}
if (!$ok) {
return xmlrpc_error(-32602, t('Server error. Invalid method parameters.'));
}
}
}
/*
if (count($args) == 1) {
// If only one parameter just send that instead of the whole array
$args = $args[0];
}
*/
if (!function_exists($method)) {
return xmlrpc_error(-32601, t('Server error. Requested function @method does not exist.', array(
"@method" => $method,
)));
}
// Call the mapped function
return call_user_func_array($method, $args);
}