4.6.x xmlrpc.inc xmlrpc()
4.7.x common.inc xmlrpc($url)
5.x common.inc xmlrpc($url)
6.x common.inc xmlrpc($url)
7.x common.inc xmlrpc($url, $args, $options = array())

Performs one or more XML-RPC request(s).

Usage example:

$result = xmlrpc('http://example.com/xmlrpc.php', array(
  'service.methodName' => array($parameter, $second, $third),
));

Parameters

$url: An absolute URL of the XML-RPC endpoint.

$args: An associative array whose keys are the methods to call and whose values are the arguments to pass to the respective method. If multiple methods are specified, a system.multicall is performed.

$options: (optional) An array of options to pass along to drupal_http_request().

Return value

For one request: Either the return value of the method on success, or FALSE. If FALSE is returned, see xmlrpc_errno() and xmlrpc_error_msg(). For multiple requests: An array of results. Each result will either be the result returned by the method called, or an xmlrpc_error object if the call failed. See xmlrpc_error().

6 calls to xmlrpc()
XMLRPCBasicTestCase::testListMethods in modules/simpletest/tests/xmlrpc.test
Ensure that a basic XML-RPC call with no parameters works.
XMLRPCBasicTestCase::testMethodSignature in modules/simpletest/tests/xmlrpc.test
Ensure that system.methodSignature returns an array of signatures.
XMLRPCMessagesTestCase::testAlterListMethods in modules/simpletest/tests/xmlrpc.test
Ensure that hook_xmlrpc_alter() can hide even builtin methods.
XMLRPCMessagesTestCase::testMulticallLimit in modules/simpletest/tests/xmlrpc.test
Test limits on system.multicall that can prevent brute-force attacks.
XMLRPCMessagesTestCase::testSizedMessages in modules/simpletest/tests/xmlrpc.test
Make sure that XML-RPC can transfer large messages.

... See full list

3 string references to 'xmlrpc'
xmlrpc.php in ./xmlrpc.php
PHP page for handling incoming XML-RPC requests from clients.
xmlrpc_server in includes/xmlrpcs.inc
Invokes XML-RPC methods on this server.
xmlrpc_server_get_capabilities in includes/xmlrpcs.inc
Returns a list of the capabilities of this server.

File

includes/common.inc, line 8320
Common functions that many Drupal modules will need to reference.

Code

function xmlrpc($url, $args, $options = array()) {
  require_once DRUPAL_ROOT . '/includes/xmlrpc.inc';
  return _xmlrpc($url, $args, $options);
}

Comments

primerg’s picture

This is how you would use drupal's xmlrpc to call another drupal site

$result = xmlrpc('http://drupal-install-domain.com/xmlrpc.php', array(
    array('system.method', $param1, $param2, $param3),
));
atchijov’s picture

This is incorrect. Second parameter has to be assoc array. Correct code:

$result = xmlrpc('http://drupal-install-domain.com/xmlrpc.php', array(
    'system.method' => array( $param1, $param2, $param3),
));
zserno’s picture

This works (note the empty array() of parameters):
$methods = xmlrpc($url, array('system.listMethods' => array()));

atchijov’s picture

Even though xmlrpc supports specifying more than one method in args array, one obvious limitation is that you can not specify the same method (key) more than once. Solution is to use built-in 'system.multicall' method:

$rc = xmlrpc( $xmlrpc_url, array(
  'system.multicall' => array(
    array( 'methodName ' => '<method name1>', 'params' => array( <param 1.1>, ...)),
    array( 'methodName ' => '<method name2>', 'params' => array( <param 2.1>, ...)),
    ...
    array( 'methodName ' => '<method nameN>', 'params' => array( <param N.1>, ...)),
  )
));
aendrew’s picture

It seems if you need to provide parameters to the method (Such as I did when implementing something from Magento's XML-RPC API), you provide them as an array without named keys.

For instance, the docs at http://www.magentocommerce.com/api/soap/catalog/catalogCategory/catalog_... say the catalog_category.tree method takes three arguments: session, parent category and store view. You'd think the call would look something like this:

xmlrpc($apiUrl, array(
        'call' => array(
               'catalog_category.tree',
               'sessionId' => $session,
               'parentId' => $parent,
               'storeView' => $viewId
        )
    )
);

In reality, it came out as such:

xmlrpc($apiUrl, array(
        'call' => array(
            $session,
            'catalog_category.tree',
            array(
                $parent,
                $viewId
            )
        )
    )
);

Note that this might just be weirdness with how the Magento API does XML-RPC calls (See: http://www.magentocommerce.com/api/soap/introduction.html#Introduction-X...), I'm really not sure -- haven't done a lot with XML-RPC.