1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 import sys
18 sys.path.append('../')
19
20 import logging
21 import traceback as tb
22 import suds.metrics as metrics
23 from tests import *
24 from suds import *
25 from suds.client import Client
26 from datetime import datetime
27
28 errors = 0
29
30 setup_logging()
31
32
33
34 url = 'http://localhost:8080/axis2/services/BasicService?wsdl'
35
36 print 'url=%s' % url
37
38
39
40
41 client = Client(url)
42
43
44
45
46 print client
47
48 print 'printList()'
49 print client.service.printList(['a','b'])
50
51
52
53
54 print 'create name'
55 name = client.factory.create('ns2:Name')
56 name.first = u'jeff'+unichr(1234)
57 name.last = 'ortel'
58
59 print name
60
61
62
63
64 print 'create phone'
65 phoneA = client.factory.create('ns2:Phone')
66 phoneA.npa = 410
67 phoneA.nxx = 822
68 phoneA.number = 5138
69
70 phoneB = client.factory.create('ns2:Phone')
71 phoneB.npa = 919
72 phoneB.nxx = 606
73 phoneB.number = 4406
74
75
76
77
78 dog = client.factory.create('ns2:Dog')
79 print dog
80 dog.name = 'Chance'
81 dog.trained = True
82 print dog
83
84
85
86
87 person = client.factory.create('ns2:Person')
88
89
90
91
92 print '{empty} person=\n%s' % person
93
94 person.name = name
95 person.age = None
96 person.birthday = datetime.now()
97 person.phone.append(phoneA)
98 person.phone.append(phoneB)
99 person.pets.append(dog)
100
101
102
103
104 print 'person=\n%s' % person
105
106
107
108
109 print 'addPersion()'
110 result = client.service.addPerson(person)
111 print '\nreply(\n%s\n)\n' % result.encode('utf-8')
112
113
114
115
116 newname = client.factory.create('ns2:Name')
117 newname.first = 'Todd'
118 newname.last = None
119
120
121
122
123 print 'updatePersion()'
124 result = client.service.updatePerson(person, newname)
125 print '\nreply(\n%s\n)\n' % str(result)
126 result = client.service.updatePerson(person, None)
127 print '\nreply(\n%s\n)\n' % str(result)
128
129
130
131
132
133 print 'echo()'
134 client.service.echo(None)
135 result = client.service.echo('this is cool')
136 print '\nreply( %s )\n' % str(result)
137
138 print 'echo() with {none}'
139 result = client.service.echo(None)
140 print '\nreply( %s )\n' % str(result)
141
142
143
144
145 print 'hello()'
146 result = client.service.hello()
147 print '\nreply( %s )\n' % str(result)
148
149
150
151
152 try:
153 print 'getVoid()'
154 result = client.service.getVoid()
155 print '\nreply( %s )\n' % str(result)
156 except Exception, e:
157 print e
158
159
160
161
162 print 'getList(list)'
163 mylist = ['my', 'dog', 'likes', 'steak']
164 result = client.service.printList(mylist)
165 print '\nreply( %s )\n' % str(result)
166
167 print 'testListArgs(tuple)'
168 mylist = ('my', 'dog', 'likes', 'steak')
169 result = client.service.printList(mylist)
170 print '\nreply( %s )\n' % str(result)
171
172
173
174
175 for n in range(0, 3):
176 print 'getList(str, %d)' % n
177 result = client.service.getList('hello', n)
178 print '\nreply( %s )\n' % str(result)
179 assert ( isinstance(result, list) and len(result) == n )
180
181 print 'addPet()'
182 dog = client.factory.create('ns2:Dog')
183 dog.name = 'Chance'
184 dog.trained = True
185 print dog
186 try:
187 result = client.service.addPet(person, dog)
188 print '\nreply( %s )\n' % str(result)
189 except Exception, e:
190 print e
191
192 print '___________________ E X C E P T I O N S __________________________'
193
194
195
196
197 try:
198 print 'throwException() faults=True'
199 result = client.service.throwException()
200 print '\nreply( %s )\n' % tostr(result)
201 except Exception, e:
202 print e
203
204
205
206
207 try:
208 print 'throwException() faults=False'
209 client.set_options(faults=False)
210 result = client.service.throwException()
211 print '\nreply( %s )\n' % tostr(result)
212 except Exception, e:
213 print e
214
215 print '\nfinished: errors=%d' % errors
216