Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 215 lines (181 sloc) 4.781 kb
7e540f9a » jortel
2008-08-05 Fix ENUMs broken during xsd package overhaul.
1 # This program is free software; you can redistribute it and/or modify
2 # it under the terms of the (LGPL) GNU Lesser General Public License as
3 # published by the Free Software Foundation; either version 3 of the
4 # License, or (at your option) any later version.
5 #
6 # This program is distributed in the hope that it will be useful,
7 # but WITHOUT ANY WARRANTY; without even the implied warranty of
8 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 # GNU Library Lesser General Public License for more details at
10 # ( http://www.gnu.org/licenses/lgpl.html ).
11 #
12 # You should have received a copy of the GNU Lesser General Public License
13 # along with this program; if not, write to the Free Software
14 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
15 # written by: Jeff Ortel ( jortel@redhat.com )
16
17 import sys
18 sys.path.append('../')
19
20 import logging
21 import traceback as tb
5bdbeafb » jortel
2008-08-05 fix metrics import
22 import suds.metrics as metrics
645d77fb » jortel
2008-08-05 move test package to tests so not to conflict with python test package
23 from tests import *
2cc3dbf7 » jortel
2008-12-04 Fix 'tag not-found' problem with rpc/encoded composte reply
24 from suds import *
7e540f9a » jortel
2008-08-05 Fix ENUMs broken during xsd package overhaul.
25 from suds.client import Client
b3a5c685 » jortel
2008-11-04 Fix unmarshaller so that xs types translated to python types aren't w…
26 from datetime import datetime
7e540f9a » jortel
2008-08-05 Fix ENUMs broken during xsd package overhaul.
27
28 errors = 0
29
30 setup_logging()
31
ed87a5b3 » jortel
2009-11-24 Provides the unmarshaller part of the 'enhanced soap encoded array su…
32 #logging.getLogger('suds.client').setLevel(logging.DEBUG)
21df2c5b » jortel
2008-08-05 change to use the tns of the wsdl containing operation and not the tn…
33
34 url = 'http://localhost:8080/axis2/services/BasicService?wsdl'
7e540f9a » jortel
2008-08-05 Fix ENUMs broken during xsd package overhaul.
35
36 print 'url=%s' % url
37
38 #
39 # create a service client using the wsdl.
40 #
8cfb25e5 » jortel
2010-01-12 Move transport caching to document-based caching. This approach lever…
41 client = Client(url)
7e540f9a » jortel
2008-08-05 Fix ENUMs broken during xsd package overhaul.
42
43 #
44 # print the service (introspection)
45 #
46 print client
47
48 print 'printList()'
49 print client.service.printList(['a','b'])
50
51 #
52 # create a name object using the wsdl
53 #
54 print 'create name'
b3a5c685 » jortel
2008-11-04 Fix unmarshaller so that xs types translated to python types aren't w…
55 name = client.factory.create('ns2:Name')
7e540f9a » jortel
2008-08-05 Fix ENUMs broken during xsd package overhaul.
56 name.first = u'jeff'+unichr(1234)
57 name.last = 'ortel'
58
59 print name
60
61 #
62 # create a phone object using the wsdl
63 #
64 print 'create phone'
b3a5c685 » jortel
2008-11-04 Fix unmarshaller so that xs types translated to python types aren't w…
65 phoneA = client.factory.create('ns2:Phone')
7e540f9a » jortel
2008-08-05 Fix ENUMs broken during xsd package overhaul.
66 phoneA.npa = 410
67 phoneA.nxx = 822
68 phoneA.number = 5138
69
b3a5c685 » jortel
2008-11-04 Fix unmarshaller so that xs types translated to python types aren't w…
70 phoneB = client.factory.create('ns2:Phone')
7e540f9a » jortel
2008-08-05 Fix ENUMs broken during xsd package overhaul.
71 phoneB.npa = 919
72 phoneB.nxx = 606
73 phoneB.number = 4406
74
75 #
76 # create a dog
77 #
b3a5c685 » jortel
2008-11-04 Fix unmarshaller so that xs types translated to python types aren't w…
78 dog = client.factory.create('ns2:Dog')
7e540f9a » jortel
2008-08-05 Fix ENUMs broken during xsd package overhaul.
79 print dog
80 dog.name = 'Chance'
81 dog.trained = True
82 print dog
83
84 #
85 # create a person object using the wsdl
86 #
b3a5c685 » jortel
2008-11-04 Fix unmarshaller so that xs types translated to python types aren't w…
87 person = client.factory.create('ns2:Person')
7e540f9a » jortel
2008-08-05 Fix ENUMs broken during xsd package overhaul.
88
89 #
90 # inspect empty person
91 #
92 print '{empty} person=\n%s' % person
93
94 person.name = name
e56be8b0 » jortel
2008-11-05 fix ( None ) value problem. Moved checking for ( None ) when translat…
95 person.age = None
b3a5c685 » jortel
2008-11-04 Fix unmarshaller so that xs types translated to python types aren't w…
96 person.birthday = datetime.now()
7e540f9a » jortel
2008-08-05 Fix ENUMs broken during xsd package overhaul.
97 person.phone.append(phoneA)
98 person.phone.append(phoneB)
99 person.pets.append(dog)
100
101 #
102 # inspect person
103 #
104 print 'person=\n%s' % person
105
106 #
107 # add the person (using the webservice)
108 #
109 print 'addPersion()'
110 result = client.service.addPerson(person)
111 print '\nreply(\n%s\n)\n' % result.encode('utf-8')
112
113 #
114 # create a new name object used to update the person
115 #
b3a5c685 » jortel
2008-11-04 Fix unmarshaller so that xs types translated to python types aren't w…
116 newname = client.factory.create('ns2:Name')
7e540f9a » jortel
2008-08-05 Fix ENUMs broken during xsd package overhaul.
117 newname.first = 'Todd'
118 newname.last = None
119
120 #
121 # update the person's name (using the webservice) and print return person object
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 # invoke the echo service
132 #
133 print 'echo()'
e56be8b0 » jortel
2008-11-05 fix ( None ) value problem. Moved checking for ( None ) when translat…
134 client.service.echo(None)
7e540f9a » jortel
2008-08-05 Fix ENUMs broken during xsd package overhaul.
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 # invoke the hello service
144 #
145 print 'hello()'
146 result = client.service.hello()
147 print '\nreply( %s )\n' % str(result)
148
149 #
150 # invoke the testVoid service
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 # test list args
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 # tuple
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 # test list returned
174 #
ed87a5b3 » jortel
2009-11-24 Provides the unmarshaller part of the 'enhanced soap encoded array su…
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 )
7e540f9a » jortel
2008-08-05 Fix ENUMs broken during xsd package overhaul.
180
181 print 'addPet()'
b3a5c685 » jortel
2008-11-04 Fix unmarshaller so that xs types translated to python types aren't w…
182 dog = client.factory.create('ns2:Dog')
7e540f9a » jortel
2008-08-05 Fix ENUMs broken during xsd package overhaul.
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 # test exceptions
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 # test faults
206 #
207 try:
208 print 'throwException() faults=False'
2cc3dbf7 » jortel
2008-12-04 Fix 'tag not-found' problem with rpc/encoded composte reply
209 client.set_options(faults=False)
7e540f9a » jortel
2008-08-05 Fix ENUMs broken during xsd package overhaul.
210 result = client.service.throwException()
211 print '\nreply( %s )\n' % tostr(result)
212 except Exception, e:
213 print e
214
563d8e95 » jortel
2008-11-05 Add XString; Enhance handling of None values for non-string XS types;…
215 print '\nfinished: errors=%d' % errors
Something went wrong with that request. Please try again.