Skip to content

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
7e540f9 Fix ENUMs broken during xsd package overhaul.
jortel authored
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
5bdbeaf fix metrics import
jortel authored
22 import suds.metrics as metrics
645d77f move test package to tests so not to conflict with python test package
jortel authored
23 from tests import *
2cc3dbf Fix 'tag not-found' problem with rpc/encoded composte reply
jortel authored
24 from suds import *
7e540f9 Fix ENUMs broken during xsd package overhaul.
jortel authored
25 from suds.client import Client
b3a5c68 Fix unmarshaller so that xs types translated to python types aren't wrap...
jortel authored
26 from datetime import datetime
7e540f9 Fix ENUMs broken during xsd package overhaul.
jortel authored
27
28 errors = 0
29
30 setup_logging()
31
ed87a5b Provides the unmarshaller part of the 'enhanced soap encoded array suppo...
jortel authored
32 #logging.getLogger('suds.client').setLevel(logging.DEBUG)
21df2c5 change to use the tns of the wsdl containing operation and not the tns o...
jortel authored
33
34 url = 'http://localhost:8080/axis2/services/BasicService?wsdl'
7e540f9 Fix ENUMs broken during xsd package overhaul.
jortel authored
35
36 print 'url=%s' % url
37
38 #
39 # create a service client using the wsdl.
40 #
8cfb25e Move transport caching to document-based caching. This approach leverag...
jortel authored
41 client = Client(url)
7e540f9 Fix ENUMs broken during xsd package overhaul.
jortel authored
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'
b3a5c68 Fix unmarshaller so that xs types translated to python types aren't wrap...
jortel authored
55 name = client.factory.create('ns2:Name')
7e540f9 Fix ENUMs broken during xsd package overhaul.
jortel authored
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'
b3a5c68 Fix unmarshaller so that xs types translated to python types aren't wrap...
jortel authored
65 phoneA = client.factory.create('ns2:Phone')
7e540f9 Fix ENUMs broken during xsd package overhaul.
jortel authored
66 phoneA.npa = 410
67 phoneA.nxx = 822
68 phoneA.number = 5138
69
b3a5c68 Fix unmarshaller so that xs types translated to python types aren't wrap...
jortel authored
70 phoneB = client.factory.create('ns2:Phone')
7e540f9 Fix ENUMs broken during xsd package overhaul.
jortel authored
71 phoneB.npa = 919
72 phoneB.nxx = 606
73 phoneB.number = 4406
74
75 #
76 # create a dog
77 #
b3a5c68 Fix unmarshaller so that xs types translated to python types aren't wrap...
jortel authored
78 dog = client.factory.create('ns2:Dog')
7e540f9 Fix ENUMs broken during xsd package overhaul.
jortel authored
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 #
b3a5c68 Fix unmarshaller so that xs types translated to python types aren't wrap...
jortel authored
87 person = client.factory.create('ns2:Person')
7e540f9 Fix ENUMs broken during xsd package overhaul.
jortel authored
88
89 #
90 # inspect empty person
91 #
92 print '{empty} person=\n%s' % person
93
94 person.name = name
e56be8b fix ( None ) value problem. Moved checking for ( None ) when translatin...
jortel authored
95 person.age = None
b3a5c68 Fix unmarshaller so that xs types translated to python types aren't wrap...
jortel authored
96 person.birthday = datetime.now()
7e540f9 Fix ENUMs broken during xsd package overhaul.
jortel authored
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 #
b3a5c68 Fix unmarshaller so that xs types translated to python types aren't wrap...
jortel authored
116 newname = client.factory.create('ns2:Name')
7e540f9 Fix ENUMs broken during xsd package overhaul.
jortel authored
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()'
e56be8b fix ( None ) value problem. Moved checking for ( None ) when translatin...
jortel authored
134 client.service.echo(None)
7e540f9 Fix ENUMs broken during xsd package overhaul.
jortel authored
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 #
ed87a5b Provides the unmarshaller part of the 'enhanced soap encoded array suppo...
jortel authored
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 )
7e540f9 Fix ENUMs broken during xsd package overhaul.
jortel authored
180
181 print 'addPet()'
b3a5c68 Fix unmarshaller so that xs types translated to python types aren't wrap...
jortel authored
182 dog = client.factory.create('ns2:Dog')
7e540f9 Fix ENUMs broken during xsd package overhaul.
jortel authored
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'
2cc3dbf Fix 'tag not-found' problem with rpc/encoded composte reply
jortel authored
209 client.set_options(faults=False)
7e540f9 Fix ENUMs broken during xsd package overhaul.
jortel authored
210 result = client.service.throwException()
211 print '\nreply( %s )\n' % tostr(result)
212 except Exception, e:
213 print e
214
563d8e9 Add XString; Enhance handling of None values for non-string XS types; re...
jortel authored
215 print '\nfinished: errors=%d' % errors
Something went wrong with that request. Please try again.