I'm using version 0.3.4 to parse UV index values from epa.gov's SunWise SOAP service. The output includes a complex type with 3 values: alert, forecastDate and index.
The result XML is: <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance%22%3E soapenv:Body <ns1:getUVIndexAlertByZipCodeResponse soapenv:encodingStyle=" http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="urn:uvindexalert"> <getUVIndexAlertByZipCodeReturn href="#id0"/> </ns1:getUVIndexAlertByZipCodeResponse> <multiRef id="id0" soapenc:root="0" soapenv:encodingStyle=" http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns2:UVIndexAlertResult" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns2="urn:uvindexalert"> <alert xsi:type="xsd:boolean">false</alert> <forecastDate xsi:type="xsd:date">2009-02-25</forecastDate> <index xsi:type="xsd:int">4</index> </multiRef> </soapenv:Body> </soapenv:Envelope>
The forecastDate is returned as <forecastDate xsi:type="xsd:date">2009-02-25</forecastDate>, which would suggest it be handled as an XDate. The traceback location (line 226) suggests that suds is actually treating it as an XDateTime and splitting on a non-existent "T" character.
from suds.client import Client url = 'http://iaspub.epa.gov/uvindexalert/services/UVIndexAlertPort?wsdl' client = Client(url) client.service.getUVIndexAlertByZipCode(in0='37919')
Traceback (most recent call last): File "<stdin>", line 1, in ? File "build/bdist.linux-x86_64/egg/suds/client.py", line 228, in __call__ File "build/bdist.linux-x86_64/egg/suds/client.py", line 367, in call File "build/bdist.linux-x86_64/egg/suds/client.py", line 228, in __call__ File "build/bdist.linux-x86_64/egg/suds/client.py", line 410, in call File "build/bdist.linux-x86_64/egg/suds/client.py", line 468, in invoke File "build/bdist.linux-x86_64/egg/suds/client.py", line 493, in send File "build/bdist.linux-x86_64/egg/suds/client.py", line 525, in succeeded File "build/bdist.linux-x86_64/egg/suds/bindings/binding.py", line 135, in get_reply File "build/bdist.linux-x86_64/egg/suds/bindings/unmarshaller.py", line 302, in process File "build/bdist.linux-x86_64/egg/suds/bindings/unmarshaller.py", line 87, in process File "build/bdist.linux-x86_64/egg/suds/bindings/unmarshaller.py", line 103, in append File "build/bdist.linux-x86_64/egg/suds/bindings/unmarshaller.py", line 180, in append_children File "build/bdist.linux-x86_64/egg/suds/bindings/unmarshaller.py", line 104, in append File "build/bdist.linux-x86_64/egg/suds/bindings/unmarshaller.py", line 404, in append_text File "build/bdist.linux-x86_64/egg/suds/bindings/unmarshaller.py", line 410, in translated File "build/bdist.linux-x86_64/egg/suds/xsd/sxdate.py", line 273, in translate File "build/bdist.linux-x86_64/egg/suds/xsd/sxdate.py", line 226, in toPython ValueError: need more than 1 value to unpack
============= Line 226 in sxdate.py is part of the XDateTime handler, not XDate as expected.
Adding a filter to include a time in the output XML, makes the output parseable:
from suds.bindings.binding import Binding Binding.replyfilter = (lambda x,y: y.replace('</forecastDate>', 'T00:00:00</forecastDate>')) client.service.getUVIndexAlertByZipCode(in0='37919')
(UVIndexAlertResult){ alert = False forecastDate = 2009-02-25 00:00:00 index = 4 }
-- Jonathan