Hello, I'm using SUDS 0.4 and TGWebServices 1.2.4 to expose a webservice
which should return a ComplexType (I'm pretty new to all of this), but
something's not working correctly when this WS is invoked: the output is
what I expected it to be, but I receive it as the message of a WebFault.
Here are the details:
class AuthenticationResponse(object):
ticket = str
error = ''
def __init__(self, error="", ticket=""):
self.ticket = ticket
self.error = error
class WebService(WebServicesRoot):
@wsexpose(AuthenticationResponse)
@wsvalidate(str,str)
def authentication(self, username='', password=''):
result = AuthenticationResponse()
if not (username and password):
result.error = "Insert both username and password"; return
result
va = validate_auth(username, encrypt_pw(password)) #Checks if the
credentials are valid
if va:
ticket =
base64.urlsafe_b64encode(uuid.uuid4().bytes).replace('=', '')
mem[ticket] = dict(expires =
datetime.datetime.now()+datetime.timedelta(hours=1), user = username)
result.ticket = ticket; return result
else:
result.error = "Incorrect username or password"; return result
This is what happens:
client.service.authentication(username='foo', password='bar')
---------------------------------------------------------------------------
WebFault Traceback (most recent call last)
/home/matteo/buildout/trunk/<ipython console> in <module>()
/home/matteo/buildout/eggs/suds-0.4-py2.6.egg/suds/client.pyc in
__call__(self, *args, **kwargs)
540 return (500, e)
541 else:
--> 542 return client.invoke(args, kwargs)
543
544 def faults(self):
/home/matteo/buildout/eggs/suds-0.4-py2.6.egg/suds/client.pyc in
invoke(self, args, kwargs)
600 timer)
601 timer.start()
--> 602 result = self.send(soapenv)
603 timer.stop()
604 metrics.log.debug(
/home/matteo/buildout/eggs/suds-0.4-py2.6.egg/suds/client.pyc in send(self,
soapenv)
647 else:
648 log.error(self.last_sent())
--> 649 result = self.failed(binding, e)
650 return result
651
/home/matteo/buildout/eggs/suds-0.4-py2.6.egg/suds/client.pyc in
failed(self, binding, error)
700 if status == 500:
701 if len(reply) > 0:
--> 702 r, p = binding.get_fault(reply)
703 self.last_received(r)
704 return (status, p)
/home/matteo/buildout/eggs/suds-0.4-py2.6.egg/suds/bindings/binding.pyc in
get_fault(self, reply)
263 p = unmarshaller.process(fault)
264 if self.options().faults:
--> 265 raise WebFault(p, faultroot)
266 return (faultroot, p.detail)
267
WebFault: Server raised fault: '(('result', <type 'str'>, {'ticket':
'blahblahblahdiblah', 'error': ''}), {}, <bound method SoapController.index
of <tgwebservices.soap.SoapController object at 0x1d141d10>>)'
I was expecting an instance of the AuthenticationResponse object with the
correct parameters being set.
What am I doing wrong? Is this something about SUDS or TGWS?
Thanks in advance for your support.