root / trunk / docs / uporaba.rst @ 6
History | View | Annotate | Download (914 Bytes)
1 |
Uporaba |
---|---|
2 |
================ |
3 |
|
4 |
Primeri uporabe web servisa za Python in SOAP knjižico `SUDS <https://fedorahosted.org/suds/>`_, ki jo namestimo z: :: |
5 |
|
6 |
sudo easy_install suds |
7 |
|
8 |
Nadzorni modul |
9 |
-------------- |
10 |
Nadozrni modul skrbi za dostop do naprave. |
11 |
:: |
12 |
|
13 |
from suds.client import Client |
14 |
client = Client(url) |
15 |
|
16 |
url = 'http://<webservice_host>/lidar/LIDAR?wsdl' |
17 |
api_key = 'api_key' |
18 |
username = 'username' |
19 |
password = 'password' |
20 |
|
21 |
Avtentikacija |
22 |
^^^^^^^^^^^^^ |
23 |
:: |
24 |
|
25 |
auth_token = client.service.getAuthenticationToken(api_key, username, password) |
26 |
if auth_token != None: |
27 |
print 'Authenticated! Auth token: %s' % auth_token |
28 |
|
29 |
Zaklep |
30 |
^^^^^^ |
31 |
:: |
32 |
|
33 |
lock_token = client.service.getLockToken(auth_token) |
34 |
if lock_token != None: |
35 |
print 'Locked! Lock token: %s' % lock_token |
36 |
|
37 |
Odklep |
38 |
^^^^^^ |
39 |
:: |
40 |
|
41 |
unlock = client.service.unlock(lock_token) |
42 |
if unlock: |
43 |
print 'Unlocked!' |
44 |
|
45 |
|