function xmlrpc_server_call in Drupal 7
Same name and namespace in other branches
- 4 includes/xmlrpcs.inc \xmlrpc_server_call()
- 5 includes/xmlrpcs.inc \xmlrpc_server_call()
- 6 includes/xmlrpcs.inc \xmlrpc_server_call()
Dispatches an XML-RPC request and any parameters to the appropriate handler.
Parameters
object $xmlrpc_server: Object containing information about this XML-RPC server, the methods it provides, their signatures, etc.
string $methodname: The external XML-RPC method name; e.g., 'system.methodHelp'.
array $args: Array containing any parameters that are to be sent along with the request.
Return value
The results of the call.
2 calls to xmlrpc_server_call()
- xmlrpc_server in includes/
xmlrpcs.inc - Invokes XML-RPC methods on this server.
- xmlrpc_server_multicall in includes/
xmlrpcs.inc - Dispatches multiple XML-RPC requests.
File
- includes/
xmlrpcs.inc, line 180 - Provides API for defining and handling XML-RPC requests.
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 (!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);
}