Hi everyone! Thank you for suds! I'm having some trouble tracking down the
reason for this cryptic 'Bad Request' exception.
I'm using Ubuntu 9.04, and suds version: 0.3.9 GA build: R659-20100219
Here is my source:
############################################
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
URL = 'https://uno.grtrdms.com/FusionServices/DataDump.svc?wsdl'
client = Client(URL, transport = https)
# update the client with some options
client.set_options(location='
https://www.grtdev1.com/FusionServices/DataDump.svc')
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:
*************************************************************
Suds (
https://fedorahosted.org/suds/ ) version: 0.3.9 GA build:
R659-20100219Service ( DataDump )
tns="http://tempuri.org/"
Prefixes (5)
ns0 = "http://schemas.datacontract.org/2004/07/PublicDTO"
ns1 = "
http://schemas.datacontract.org/2004/07/PublicDTO.Data_Transfer_Objects&q...
ns2 = "
http://schemas.datacontract.org/2004/07/PublicDTO.RequestResponse"
ns3 = "http://schemas.microsoft.com/2003/10/Serialization/"
ns4 = "http://schemas.microsoft.com/2003/10/Serialization/Arrays"
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...
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DEBUG:suds.client:sending tooo (
https://www.grtdev1.com/FusionServices/DataDump.svc)
message:
<SOAP-ENV:Envelope
xmlns:ns0="http://www.grt.com/Services/SOAP/DataDump"
xmlns:ns1="http://tempuri.org" xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENV="
http://tempuri.org">
<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:headers = {'SOAPAction': u'"
http://www.grt.com/Services/SOAP/DataDump/IDataDump/GetData"';,
'Content-Type': 'text/xml'}
DEBUG:suds.transport.http:sending:
URL:https://www.grtdev1.com/FusionServices/DataDump.svc
HEADERS: {'SOAPAction': u'"
http://www.grt.com/Services/SOAP/DataDump/IDataDump/GetData"';,
'Content-Type': 'text/xml', 'Content-type': 'text/xml',
'Soapaction': u'"
http://www.grt.com/Services/SOAP/DataDump/IDataDump/GetData"'}
MESSAGE:
<SOAP-ENV:Envelope
xmlns:ns0="http://www.grt.com/Services/SOAP/DataDump"
xmlns:ns1="http://tempuri.org" xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENV="
http://tempuri.org">
<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:Envelope
xmlns:ns0="http://www.grt.com/Services/SOAP/DataDump"
xmlns:ns1="http://tempuri.org" xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENV="
http://tempuri.org">
<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.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Thanks and best regards,
Jake
Jake Emerson
Spatial Information Science and Engineering
University of Maine
127 Boardman Hall
jakeemerson(a)spatial.maine.edu
http://www.spatial.maine.edu/~jakeemerson