Revision 8
uporaba.rst | ||
---|---|---|
1 | 1 |
Uporaba |
2 | 2 |
================ |
3 | 3 |
|
4 |
Primeri uporabe web servisa za Python in SOAP knjižico `SUDS <https://fedorahosted.org/suds/>`_, ki jo namestimo z: :: |
|
4 |
Primeri uporabe web servisa na Ubuntu 10.04 za Python in SOAP knjižico `SUDS <https://fedorahosted.org/suds/>`_, ki jo namestimo z: ::
|
|
5 | 5 |
|
6 | 6 |
sudo easy_install suds |
7 | 7 |
|
... | ... | |
11 | 11 |
:: |
12 | 12 |
|
13 | 13 |
from suds.client import Client |
14 |
client = Client(url)
|
|
14 |
management = Client(url)
|
|
15 | 15 |
|
16 |
url = 'http://<webservice_host>/lidar/LIDAR?wsdl'
|
|
16 |
url = 'http://<webservice_host>/lidar/Management?wsdl'
|
|
17 | 17 |
api_key = 'api_key' |
18 | 18 |
username = 'username' |
19 | 19 |
password = 'password' |
... | ... | |
22 | 22 |
^^^^^^^^^^^^^ |
23 | 23 |
:: |
24 | 24 |
|
25 |
auth_token = client.service.getAuthenticationToken(api_key, username, password)
|
|
25 |
auth_token = management.service.getAuthenticationToken(api_key, username, password)
|
|
26 | 26 |
if auth_token != None: |
27 |
print 'Authenticated! Auth token: %s' % auth_token
|
|
27 |
print 'Prijavljen! Auth token: %s' % auth_token
|
|
28 | 28 |
|
29 | 29 |
Zaklep |
30 | 30 |
^^^^^^ |
31 | 31 |
:: |
32 | 32 |
|
33 |
lock_token = client.service.getLockToken(auth_token) |
|
34 |
if lock_token != None: |
|
35 |
print 'Locked! Lock token: %s' % lock_token |
|
33 |
status = management.service.getStatus(auth_token) |
|
34 |
if status == 'unlocked': |
|
35 |
lock_token = management.service.getLockToken(auth_token) |
|
36 |
if lock_token != None: |
|
37 |
print 'Naprava zaklenjena! Lock token: %s' % lock_token |
|
38 |
|
|
39 |
# TODO: Uporaba zaklenjene naprave z uporabo lock_token |
|
36 | 40 |
|
37 | 41 |
Odklep |
38 | 42 |
^^^^^^ |
39 | 43 |
:: |
40 | 44 |
|
41 |
unlock = client.service.unlock(lock_token)
|
|
45 |
unlock = management.service.unlock(lock_token)
|
|
42 | 46 |
if unlock: |
43 |
print 'Unlocked!'
|
|
47 |
print 'Naprava odklenjena!'
|
|
44 | 48 |
|
45 | 49 |
|
Also available in: Unified diff