server.py
#encoding=utf-8
#!/usr/bin/env python
from SimpleXMLRPCServer import SimpleXMLRPCServer
import os
server = SimpleXMLRPCServer(('localhost', 9000))
# Expose a function with an alternate name
def list_contents(dir_name):
return os.listdir(dir_name)
server.register_function(list_contents, 'dir')
def get_users_blogs(blogid,user,password):
return [{'url': 'http://www.cnblogs.com/lexus/', 'blogid': '25231', 'blogName': u'\u6717\u5fd7\u5de5\u4f5c\u5ba4(Langzhi Studio)'}]
server.register_function(get_users_blogs, 'blogger.getUsersBlogs')
try:
print 'Use Control-C to exit'
server.serve_forever()
except KeyboardInterrupt:
print 'Exiting'
client.py
#encoding=utf-8
#!/usr/bin/env python
import xmlrpclib
#proxy = xmlrpclib.Server('http://www.cnblogs.com/aa/services/metaweblog.aspx')
proxy = xmlrpclib.Server('http://localhost:9000')
print proxy.blogger.getUsersBlogs("23451","aa","bb")
reference:
http://www.doughellmann.com/PyMOTW/SimpleXMLRPCServer/#module-SimpleXMLRPCServer
http://docs.python.org/library/simplexmlrpcserver.html
http://twistedmatrix.com/documents/current/web/howto/xmlrpc.html
http://www.tutorialspoint.com/xml-rpc/xml_rpc_examples.htm
http://docs.python.org/library/xmlrpclib.html
https://github.com/huafengxi/pblog
http://www.allyourpixel.com/tag/Django/
http://www.cppblog.com/ronliu/services/metaweblog.aspx