You are here

function xmlrpc_server_call_wrapper in Services 6.3

Same name and namespace in other branches
  1. 5 servers/xmlrpc_server/xmlrpc_server.module \xmlrpc_server_call_wrapper()
  2. 6 servers/xmlrpc_server/xmlrpc_server.module \xmlrpc_server_call_wrapper()
  3. 6.2 servers/xmlrpc_server/xmlrpc_server.module \xmlrpc_server_call_wrapper()
  4. 7.3 servers/xmlrpc_server/xmlrpc_server.module \xmlrpc_server_call_wrapper()
  5. 7 servers/xmlrpc_server/xmlrpc_server.module \xmlrpc_server_call_wrapper()

Pass XMLRPC server requests to the appropriate services method.

This function can take varying parameters as are appropriate to the service in question.

1 string reference to 'xmlrpc_server_call_wrapper'
xmlrpc_server_xmlrpc in servers/xmlrpc_server/xmlrpc_server.module
Return an array of all defined services methods and callbacks.

File

servers/xmlrpc_server/xmlrpc_server.module, line 60
Enable XML-RPC for services module.

Code

function xmlrpc_server_call_wrapper() {
  $xmlrpc_server = xmlrpc_server_get();
  $method_name = $xmlrpc_server->message->methodname;
  $args = func_get_args();
  $endpoint = services_get_server_info('endpoint', '');
  $controller = services_controller_get($method_name, $endpoint);
  try {

    // Add in default arguments if arguments still dont exist.
    if (isset($controller['args']) && is_array($controller['args'])) {
      foreach ($controller['args'] as $index => $arg) {
        if ($arg['optional'] && isset($arg['default value']) && !isset($args[$index])) {
          $args[$index] = $arg['default value'];
        }
        elseif ($arg['optional'] == FALSE && !isset($args[$index])) {
          return services_error(t('Missing required argument @arg', array(
            '@arg' => $arg['name'],
          )), 401);
        }
      }
    }
    return services_controller_execute($controller, $args);
  } catch (Exception $e) {
    return xmlrpc_error($e
      ->getCode(), $e
      ->getMessage());
  }
}