简单xmlrpc服务器

import calendar, SimpleXMLRPCServer



class Calendar:

    def getMonth(self, year, month):

        return calendar.month(year, month)



    def getYear(self, year):

        return calendar.calendar(year)



calendar_object = Calendar()

server = SimpleXMLRPCServer.SimpleXMLRPCServer(('localhost', 8888))

server.register_instance(calendar_object)

print "Listening on port 8888"

server.serve_forever()  

import xmlrpclib
server = xmlrpclib.ServerProxy("http://localhost:8888")
month = server.getMonth( 2013, 6)
print month

简单xmlrpc服务器

你可能感兴趣的:(xml)