Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 5ab2b051c4
Fetching contributors…

Cannot retrieve contributors at this time

63 lines (51 sloc) 1.977 kb
layout title


This is a simple recipe how to use XMLRPC with

I wrote some generic xmlrpc adaptor for and drop it to, you can see this below

import web
from SimpleXMLRPCServer import SimpleXMLRPCDispatcher
dispatcher = SimpleXMLRPCDispatcher(allow_none = False, encoding = "UTF-8")

def init(urllist):
    global dispatcher
    for it in range(len(urllist)/2):
        #dispatcher.register_function(urllist[it+1], urllist[it])
        dispatcher.register_function(urllist[(it*2)+1], urllist[(it*2)])

class rpc:
    def GET(self):
        global dispatcher
        methods = dispatcher.system_listMethods()
        web.header('Content-Type', 'text/html')
        print "<body><h1>Error!</h1>"
        print "Method GET is not alowed for XMLRPC requests"
        print "List of available methods:"
        print "<ul>"
        for method in methods:
            sig = dispatcher.system_methodSignature(method)
            help =  dispatcher.system_methodHelp(method)
            print "<li><b>%s</b>: [%s] %s</li>" % (method, sig, help)
        print "</ul>"
        print "Be careful"
        print "</body>"
    def POST(self):
        global dispatcher
        response = dispatcher._marshaled_dispatch(
        web.header('Content-length', str(len(response)))
        print response

This library slightly based on xmlrpc Django code, but rewriten from scratch at last stage. Now look at simple usage pattern

import web
import webxml

def multiply(x,y):
    return x*y

xmlrpcurls = (
    'mult', multiply
    # Look! First parameter is a public name, second is a lambda value, not string!
urls = (
    '/rpc/', 'webxml.rpc'    )

if __name__ == "__main__":, globals())
Jump to Line
Something went wrong with that request. Please try again.