Hey folks. I'm a new hire here at the pingVision ranch, and so I've not had a lot to say, but some of my esteemed colleagues suggested I share this tidbit.
I recently had to create a small, simple xmlrpc service in a Drupal project. That involves hook_xmlrpc, which is very well documented and is pretty darn easy to use. However, for testing purposes I needed to throw together a simple page to hit my service and display what it found. After a little googling, I found this page: http://keithdevens.com/software/xmlrpc.
If you download the source he's sharing there, then you can set up a simple xml client like so:
<?php
require_once 'source.php';
define("XMLRPC_DEBUG", 1);
XMLRPC_request('time.xmlrpc.com', '/RPC2', 'currentTime.getCurrentTime', NULL, NULL);
print_r($result);
XMLRPC_debug_print();
?>This works very well - the first parameter is the host you're going to, the second is the path - for hook_xmlrpc in Drupal it's going to be either '/xmlrpc.php' or the like - the third parameter is the method name, the fourth is an array of parameters for the method, and the last is some sort of user_agent, which I don't currently understand the purpose of. (Apparently it's the browser you're querying from, or something like that - as far as I can see, leaving it NULL is fine.)
Naturally the print_r($result) gives you the result on the screen, but the XMLRPC_debug_print() function additionally gives you a lot of debugging information for your rpc call - the xml you sent, the xml you received, and another view of the data that XMLRPC_request returned.
I hope that's helpful to folks out there, and I look forward to learning more about Drupal's many interesting features.
- Tags: testing, hook_xmlrpc, xmlrpc, code, Drupal








Comments
moshe weitzman writes:
i always used a neat desktop app for OSX - see http://www.ditchnet.org/xmlrpc/
toemaz writes:
Do you know a similar xml-rpc client for windows? I have been looking for it for quite some time now.