1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
#!/usr/bin/env python
"""
Synopsis:
Implement an XML-RPC client that "calls" the functions provided by
your XML-RPC server.
Usage:
python xmlrpcclient1.py
Hints:
- module SimpleXMLRPCServer in the Python standard library.
- module xmlrpclib in the Python standard library.
Solution:
Solutions/xmlrpcclient1.py
"""
import xmlrpclib
def test():
server = xmlrpclib.ServerProxy('http://localhost:8000')
print 'pow(2, 3) --', server.pow(2, 3) # Returns 2**3 = 8
print 'add(2, 3) --', server.add(2, 3) # Returns 5
print 'div(5, 2) --', server.div(5, 2) # Returns 5//2 = 2
# Print list of available methods
print server.system.listMethods()
if __name__ == '__main__':
test()
|