rancavil/tornado-webservices — Issue #11: Request boolean complex type parses incorrectly
Author: RANUX
Created: 2012-01-09 13:48:38+00:00
State: open

I have next test case:

CertService.py source code:

import logging
import tornado.ioloop
from tornadows import soaphandler, webservices, complextypes
from tornadows.soaphandler import webservice
import datetime

class InputRequest(complextypes.ComplexType):
idperson = str
is_new = bool

class CertificateResponse(complextypes.ComplexType):
numcert = int
idperson = str
nameperson = str
birthday = datetime.date
datetimecert = datetime.datetime
isvalid = bool

class CertService(soaphandler.SoapHandler):

@webservice(_params=InputRequest, _returns=CertificateResponse)
def getCertificate(self, input):
idperson = input.idperson

if type(input.is_new) != bool:
print '---------DEBUG------------'
print '%s %s' % (input.is_new, type(input.is_new))
raise Exception("Type mismathch")

cert = CertificateResponse()
cert.numcert = 1
cert.idperson = idperson
cert.nameperson = 'Steve J'
cert.birthday = datetime.date(1973,12,11)
cert.datetimecert = datetime.datetime.now()
cert.isvalid = True

return cert

if __name__ == '__main__':
logging.basicConfig(level=logging.INFO)
logging.getLogger("tornadows.soaphandler").setLevel(logging.DEBUG)
logging.getLogger("tornadows.webservices").setLevel(logging.DEBUG)
service = [('CertService',CertService)]
app = webservices.WebService(service)
app.listen(8080)
tornado.ioloop.IOLoop.instance().start()

Suds request:
```
>>> client.service.getCertificate(idperson='0-9', is_new=True)
DEBUG:suds.client:sending to (http://127.0.1.1:8080/CertService)
message:

0-9
true

DEBUG:suds.client:headers = {'SOAPAction': u'"http://127.0.1.1:8080/CertService"', 'Content-Type': 'text/xml; charset=utf-8'}
DEBUG:suds.transport.http:sending:
URL:http://127.0.1.1:8080/CertService
HEADERS: {'SOAPAction': u'"http://127.0.1.1:8080/CertService"', 'Content-Type': 'text/xml; charset=utf-8', 'Content-type': 'text/xml; charset=utf-8', 'Soapaction': u'"http://127.0.1.1:8080/CertService"'}
MESSAGE:
0-9true
DEBUG:suds.transport.http:received:
CODE: 200
HEADERS: {'content-length': '490', 'content-type': 'text/xml', 'server': 'TornadoServer/2.1.1'}
MESSAGE:

Error in web service : Type mismathch

DEBUG:suds.client:http succeeded:

Error in web service : Type mismathch

```
Server debug output:

$ python CertService.py
INFO:root:200 GET /CertService?wsdl (127.0.0.1) 23.23ms
---------DEBUG------------
true type 'str'