Example: XML-RPC

  1. drupal
    1. 8
    2. 6
    3. 7

Demonstration of XML-RPC in Drupal 7.

This is an example of how to implement and XML-RPC server by registering callbacks to specific methods and how to make xmlrpc calls using the built-in xmlrpc() factory provided by Drupal.

For experimentation you may be interested in the XML-RPC Tester module.

Note that the Services module is another common way to do XML-RPC at this time.

See also

hook_xmlrpc()

xmlrpc()

xmlrpc_errno()

xmlrpc_error_msg()

Functions & methods

NameDescription
xmlrpc_example_alter_formPresent a form to enable or disable the code implemented in hook_xmlrpc_alter.
xmlrpc_example_client_add_submitSubmit: query the XML-RPC endpoint for the method xmlrpc_example.add and report the result as a Drupal message.
xmlrpc_example_client_formPresent a form to get two arguments, and make a call to an XML-RPC server using these arguments as input, showing the result in a message.
xmlrpc_example_client_multicall_submitSubmit a multicall request: query the XML-RPC endpoint for the methods xmlrpc_example.add and xmlrpc_example.subtract and report the result as a Drupal message. Drupal's XML-RPC client builds the system.multicall request automatically when there…
xmlrpc_example_client_request_methods_submitSubmit: query the XML-RPC endpoint for the method system.listMethods and report the result as a Drupal message. The result is a list of the available methods in this XML-RPC server.
xmlrpc_example_client_subtract_submitSubmit: query the XML-RPC endpoint for the method xmlrpc_example.subtract and report the result as a Drupal message.
xmlrpc_example_infoA simple landing-page information function.
xmlrpc_example_menuImplements hook_menu().
xmlrpc_example_server_formPresent a form to configure the service options. In this case the maximum and minimum values for any of the operations (add or subtraction).
xmlrpc_example_xmlrpcImplements hook_xmlrpc().
xmlrpc_example_xmlrpc_alterImplements hook_xmlrpc_alter().
_xmlrpc_example_alter_addSum the two arguments without limit checking.
_xmlrpc_example_alter_subtractReturn the difference of the two arguments without limit checking.
_xmlrpc_example_server_addThis is the callback for the xmlrpc_example.add method.
_xmlrpc_example_server_subtractThis is the callback for the xmlrpc_example.subtract xmlrpc method.

examples/xmlrpc_example/xmlrpc_example.module, line 8