To use Drupal XML-RPC is easy, let’s use the classic example Getting the Name of a State to see how to make a XML-RPC request using Drupal.
In this classic example. we are sending a parameter along with the name of the remote method we are calling. UserLand Software runs a web service at betty.userland.com that has the 50 United States listed in alphabetical order. So if we ask for state 1, it returns Alabama; state 50 is Wyoming. The name of the method is examples.getStateName. Let’s ask it for state number 3 in the list:
$state_name = xmlrpc('http://betty.userland.com/RPC2', 'examples.getStateName', 3);
This sets $state_name to Arizona. Here’s the XML Drupal sends (we’ll ignore the HTTP headers for clarity from now on):
<?xml version="1.0"?>
<methodCall>
<methodName>examples.getStateName</methodName>
<params>
<param>
<value>
<int>3</int>
</value>
</param>
</params>
</methodCall>
Here’s the response we get from betty.userland.com:
<?xml version="1.0"?>
<methodResponse>
<params>
<param>
<value>Arizona</value>
</param>
</params>
</methodResponse>
Notice that Drupal automatically saw that the parameter you sent was an integer and encoded it as such in your request. But what’s happening in the response? The value doesn’t have any type tags around it! Shouldn’t that be
Now you see how simple it is to make an XML-RPC client call in Drupal. One line:
$result = xmlrpc($url, $method, $param_1, $param_2, $param_3...)




















































