You are here

xmlrpc_server.module in Services 7

@author Services Dev Team

Enable XML-RPC for services module.

File

servers/xmlrpc_server/xmlrpc_server.module
View source
<?php

/**
 * @author Services Dev Team
 * @file
 *  Enable XML-RPC for services module.
 */

/**
 * Implements hook_server_info().
 */
function xmlrpc_server_server_info() {
  return array(
    '#name' => 'XMLRPC',
    '#path' => 'xmlrpc',
  );
}

/**
 * Implements hook_server_server().
 */
function xmlrpc_server_server() {
  require_once DRUPAL_ROOT . '/' . 'includes/xmlrpc.inc';
  require_once DRUPAL_ROOT . '/' . 'includes/xmlrpcs.inc';
  return xmlrpc_server(xmlrpc_server_xmlrpc());
}
function xmlrpc_server_xmlrpc() {
  $callbacks = array();
  foreach (services_get_all() as $method) {
    $callbacks[$method['#method']] = 'xmlrpc_server_call_wrapper';
  }
  return $callbacks;
}
function xmlrpc_server_call_wrapper() {
  $xmlrpc_server = xmlrpc_server_get();
  $method_name = $xmlrpc_server->message->methodname;
  $args = func_get_args();
  return services_method_call($method_name, $args);
}
function xmlrpc_server_server_error($message) {
  if (!is_array($message)) {
    $message = (array) $message;
  }
  $message = implode(' ', $message);
  $matches = array();
  if (preg_match("/\\#(\\d+)/", $message, $matches)) {
    $code = $matches[1];
  }
  else {
    $code = 1;
  }
  return xmlrpc_error($code, strip_tags($message));
}