Hi everyone! Thank you for suds! I'm having some trouble tracking down the reason for this cryptic 'Bad Request' exception.
import logging
import urllib2
import sys
# use an accessible copy of client.py, not the egg,
# to make the source accessible
sys.path.append('/usr/lib/python2.6/dist-packages/python-suds-0.3.9')
from suds.transport.https import HttpTransport
from suds.client import Client
logging.basicConfig(level=logging.INFO)
logging.getLogger('suds.client').setLevel(logging.DEBUG)
logging.getLogger('suds.transport').setLevel(logging.DEBUG)
logging.getLogger('suds.xsd.schema').setLevel(logging.DEBUG)
logging.getLogger('suds.wsdl').setLevel(logging.DEBUG)
# take care of content type issues...
class HTTPSudsPreprocessor(urllib2.BaseHandler):
def http_request(self, req):
typ = 'application/soap+xml; charset=utf-8'
req.add_header('Content-Type', typ)
return req
https_request = http_request
https = HttpTransport()
opener = urllib2.build_opener(HTTPSudsPreprocessor)
https.urlopener = opener
# instantiate the client
client = Client(URL, transport = https)
# update the client with some options
client.set_options(retxml=True)
client.set_options(port='BasicHttpBinding_IDataDump')
print client
userID = 'jake.emerson'
password = 'fake_pass'
configurationKey = 'Haiti_KayEN'
lastRowID = 0
maxReturnSize = 10
result = client.service.GetData(userID, password, configurationKey, lastRowID, maxReturnSize)
##############################################
The output of the "print client" statement is just what I expect:
*************************************************************
Prefixes (5)
Ports (2):
(WSHttpBinding_IDataDump)
Methods (2):
GetData(xs:string userId, xs:string password, xs:string configurationKey, xs:int lastRowId, xs:int maxReturnSize, )
GetQuestionMetaData(xs:string userId, xs:string password, xs:string configurationKey, xs:int questionId, )
Types (12):
ns1:ArrayOfAssessmentAttributeElement
ns1:ArrayOfAssessmentDetailElement
ns4:ArrayOfint
ns1:AssessmentAttributeElement
ns1:AssessmentDetailElement
ns2:DataDumpResponse
ns2:GRTBaseResponse
ns0:GRTException.EGRTErrorCode
ns2:QuestionMetadataResponse
ns3:char
ns3:duration
ns3:guid
(BasicHttpBinding_IDataDump)
Methods (2):
GetData(xs:string userId, xs:string password, xs:string configurationKey, xs:int lastRowId, xs:int maxReturnSize, )
GetQuestionMetaData(xs:string userId, xs:string password, xs:string configurationKey, xs:int questionId, )
Types (12):
ns1:ArrayOfAssessmentAttributeElement
ns1:ArrayOfAssessmentDetailElement
ns4:ArrayOfint
ns1:AssessmentAttributeElement
ns1:AssessmentDetailElement
ns2:DataDumpResponse
ns2:GRTBaseResponse
ns0:GRTException.EGRTErrorCode
ns2:QuestionMetadataResponse
ns3:char
ns3:duration
ns3:guid
*******************************************************
I cranked up the logging output, so it's a bit long...
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
message:
<SOAP-ENV:Header/>
<ns1:Body>
<ns0:GetData>
<ns0:userId>jake.emerson</ns0:userId>
<ns0:password>fake_passwd</ns0:password>
<ns0:configurationKey>Haiti_KayEN</ns0:configurationKey>
<ns0:lastRowId>0</ns0:lastRowId>
<ns0:maxReturnSize>10</ns0:maxReturnSize>
</ns0:GetData>
</ns1:Body>
</SOAP-ENV:Envelope>
DEBUG:suds.transport.http:sending:
MESSAGE:
<SOAP-ENV:Header/>
<ns1:Body>
<ns0:GetData>
<ns0:userId>jake.emerson</ns0:userId>
<ns0:password>fake_passwd</ns0:password>
<ns0:configurationKey>Haiti_KayEN</ns0:configurationKey>
<ns0:lastRowId>0</ns0:lastRowId>
<ns0:maxReturnSize>10</ns0:maxReturnSize>
</ns0:GetData>
</ns1:Body>
</SOAP-ENV:Envelope>
ERROR:suds.client:<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Header/>
<ns1:Body>
<ns0:GetData>
<ns0:userId>jake.emerson</ns0:userId>
<ns0:password>fake_passwd</ns0:password>
<ns0:configurationKey>Haiti_KayEN</ns0:configurationKey>
<ns0:lastRowId>0</ns0:lastRowId>
<ns0:maxReturnSize>10</ns0:maxReturnSize>
</ns0:GetData>
</ns1:Body>
</SOAP-ENV:Envelope>
DEBUG:suds.client:http failed:
Traceback (most recent call last):
File "/usr/lib/python2.6/dist-packages/GRT/reporting/SOAP.py", line 47, in <module>
result = client.service.GetData(userID, password, configurationKey, lastRowID, maxReturnSize)
File "/usr/lib/python2.6/dist-packages/python-suds-0.3.9/suds/client.py", line 539, in __call__
return client.invoke(args, kwargs)
File "/usr/lib/python2.6/dist-packages/python-suds-0.3.9/suds/client.py", line 598, in invoke
result = self.send(msg)
File "/usr/lib/python2.6/dist-packages/python-suds-0.3.9/suds/client.py", line 641, in send
result = self.failed(binding, e)
File "/usr/lib/python2.6/dist-packages/python-suds-0.3.9/suds/client.py", line 698, in failed
raise Exception((status, reason))
Exception: (400, u'Bad Request')
Script terminated.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%