The DocXmlRpcServer is a ''very'' simple XmlRpc server that is also simultaneously a self-documenting web server. {{{ #!python """Demonstration of the Python 2.3 DocXMLRPCServer. The demonstration publishes two functions, "message" and "wait." """ import time import socket from DocXMLRPCServer import DocXMLRPCServer class SimpleShareServer: def message(self, msg): """Print message and return True. Log everything passed to this function. """ print time.asctime(), msg return True def wait(self, seconds): """Wait a number of seconds, and return the number. Wait for a certain number of seconds before returning. Returns the same number passed in. """ print time.asctime(), "Waiting %s seconds" % seconds time.sleep(seconds) print time.asctime(), "Finished waiting %s seconds" % seconds return seconds if __name__ == '__main__': server = DocXMLRPCServer(("", 8000), logRequests=0) server.register_introspection_functions() server.register_instance(SimpleShareServer()) print time.asctime(), 'Application Starting.' server.serve_forever() print time.asctime(), 'Application Finishing.' }}} The benefit of using DocXMLRPCServer is that it automatically creates documentation for your XML-RPC server, just open a browser and head to http://localhost:8000 after starting the server. Writing a client to call the wait function is left as an exercise for the reader. :) == Resources == * XmlRpc -- general information on XML-RPC * BaseHttpServer -- class that DocXmlRpcServer inherits from * [[http://www.python.org/doc/current/lib/module-SimpleXMLRPCServer.html|SimpleXMLRPCServer documentation]] * [[http://www.python.org/doc/current/lib/module-DocXMLRPCServer.html|DocXMLRPCServer documentation]] * {{{SimpleXMLRPCServer.py}}}, and {{{DocXMLRPCServer.py}}} - comments includ many examples of use * [[http://sourceforge.net/projects/py-xmlrpc/|Fast C implementation of XML-RPC for python]] (only for python version up to 2.2) [[http://www.xmlrpc.com/discuss/msgReader$1573|(more notes on it- apparently 20-100x faster!)]] Also: * AutoXmlRpcServer -- automatically serve modules in local directory with DocXmlRpcServer == Notes == This page was based on [[http://www.seapig.org/DocXMLRPCServer|SeaPig:DocXMLRPCServer,]] with BrianDorsey's permission. = Discussion = (none yet!)