Python Module “xmlrpclib”
-
Whether you are a fan of Python or not, Python’s bundled module
xmlrpclib
from PythonWare is extremely useful for testing an XML-RPC server when used from the Python interactive shell. Sincexmlrpclib
is bundled with the standard Python 2.3 distribution, no additional installation is required. Python itself comes preinstalled on most Linux distributions and Mac OS X. Start the Python shell, and enter these commands:import xmlrpclib server = xmlrpclib.Server('http://your/server/url')
Now, you can interactively test the methods of your XML-RPC server from the Python shell. As an example, most XML-RPC server libraries include support for the
system.listMethods()
andsystem.methodSignature()
methods. To list all of the available methods on the remote server from Python, simply enter:server.system.listMethods()
The methods will be returned as a Python list and printed to
stdout
. Calling XML-RPC methods really couldn’t be any simpler. To get the signature of a method, enter:server.system.methodSignature('method_name')
The conversion of data types between Python and XML-RPC is automatically performed by the
Server
object. You can test any of your remote server’s methods as shown above. TheServer
object also provides averbose
mode that will display the raw XML-RPC transactions with the server for troubleshooting. To enableverbose
mode, instantiate theServer
like this:server = xmlrpclib.Server('http://your/server/url', verbose=True)
Interactively testing your server API like this can greatly reduce your debugging time. It is also very handy for getting to know your way around the APIs of other XML-RPC servers, such as WordPress or Flickr.