I tried to explain how to write web service server code with Python using ZSI and XML-RPC before and also i explained how to write a web service client code with Python using ZSI too. Now i want to explain how to write a web service client code with Python using XML-RPC lib.
It is simple than using ZSI again. We just first import our xmlrpclib module;
#!/usr/bin/python
import xmlrpclib
Then we give the url and create a server object;
server = xmlrpclib.Server("http://localhost/cgi-bin/index.py")
and lastly we request to the methods we want from web service with this object;
print server.asillyfunction("hello world")
Also there are methods in xmlrpclib like, to see which methods are the web service provides;
for method in server.system.listMethods():
print method
Here is the sample code. And here is a better client code. Also i want to mention again, i wrote down this code just to test my web service code that i wrote in here.
.bmp)
No comments:
Post a Comment