5
.. class:: section-title
12
Using the xmlrpclib library
14
.. sourcecode:: python
20
For each exchange with the server, don't forget to supply the user ID, the PWD and the database name
22
Web-Services - Python - Login
23
-----------------------------
25
.. sourcecode:: python
33
socket = xmlrpclib.ServerProxy( "http://localhost:8069/xmlrpc/common" )
34
user_id = socket.login( database, username, password )
36
Web-Services - Python - Search
37
------------------------------
39
.. sourcecode:: python
41
socket = xmlrpclib.ServerProxy( "http://localhost:8069/xmlrpc/object" )
43
database, user_id, password,
44
"openacademy.lecturer", "search", []
46
lecturers = socket.execute(
47
database, user_id, password,
48
"openacademy.lecturer", "read", ids, ['name', 'email']
51
for lecturer in lecturers:
52
print "lecturer: %20s - %s" % ( lecturer['name'], lecturer['email'] )
57
Using the **xmlrpc/client** library
61
require 'xmlrpc/client'
65
For each exchange with the server, don't forget to supply the user ID, the PWD and the database name
67
Web-Services - Ruby - Login
68
---------------------------
72
require 'xmlrpc/client'
78
socket = XMLRPC::Client.new( 'http://localhost', '/xmlrpc/common', 8069 )
79
user_id = socket.login( database, username, password )
81
Web-Services - Ruby - Search
82
----------------------------
86
socket = XMLRPC::Client.new( 'http://localhost', '/xmlrpc/object', 8069 )
88
database, user_id, password,
89
'openacademy.lecturer', 'search', []
91
lecturers = socket.execute(
92
database, user_id, password,
93
'openacademy.lecturer', 'read', ['name', 'email']
96
for lecturer in lecturers:
97
print "lecturer: %20s - %s" % [ lecturer['name'], lecturer['email'] ]