Coupure prévue mardi 3 Août au matin pour maintenance du serveur. Nous faisons au mieux pour que celle-ci soit la plus brève possible.

webservice.py 2.78 KB
Newer Older
Janez K's avatar
Janez K committed
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#from suds.client import Client
import pysimplesoap
from pysimplesoap.client import SoapClient

# class SudsWebService:
    # def __init__(self, wsdl_url):
        # self.client = Client(wsdl_url)
        # self.wsdl_url = wsdl_url
        # self.name = self.client.sd[0].ports[0][0].name
        # self.methods = []
        # for s in self.client.sd:
            # for p in s.ports:
                # for m in p[1]:
                    # method = {}
                    # method['name'] = m[0]
                    # method['inputs'] = []
                   # method['method'] = m
                    # for i in m[1]:
                        # input = {}
                        # input['name']=i[0]
                        # try:
                            # input['type']=i[1].type[0]
                        # except:
                            # pass
                        # method['inputs'].append(input)
                    # self.methods.append(method)
 
    # def __unicode__(self):
        # return self.wsdl_url
    
    # def __str__(self):
        # return self.wsdl_url

        
class WebService:
    def __init__(self, wsdl_url, timeout=60):
        pysimplesoap.client.TIMEOUT = timeout
        self.client = SoapClient(wsdl=wsdl_url,trace=False)
        self.wsdl_url = wsdl_url
        self.name = wsdl_url
        self.methods = []
        for service in self.client.services.values():
            for port in service['ports'].values():
                for op in port['operations'].values():
                    method = {}
                    try:
                        method['documentation']=op['documentation']
                    except:
                        method['documentation']="No documentation provided."
                    method['name']=op['name']
                    method['inputs']=[]
                    method['outputs']=[]
Janez K's avatar
Janez K committed
53
54
55
56
                    try:
                        input_dict = op['input'].values()[0]
                    except:
                        input_dict = []
Janez K's avatar
Janez K committed
57
58
59
60
61
                    for i in input_dict:
                        input = {}
                        input['name']=i
                        input['type']=input_dict[i]
                        method['inputs'].append(input)
Janez K's avatar
Janez K committed
62
63
64
65
                    try:
                        output_dict = op['output'].values()[0]
                    except:
                        output_dict = [[]]
Janez K's avatar
Janez K committed
66
67
68
69
70
71
72
73
74
75
76
                    if type(output_dict)==type([]):
                        output_dict = output_dict[0]
                    for o in output_dict:
                        output = {}
                        output['name']=o
                        method['outputs'].append(output)
                    self.methods.append(method)
    def __unicode__(self):
        return self.wsdl_url
    def __str__(self):
        return self.wsdl_url