On Monday 05 April 2010, Jeff Ortel elucidated thus:
On 04/05/2010 01:52 PM, Joshua J. Kugler wrote:
> On Monday 05 April 2010, Jeff Ortel elucidated thus:
>> On 04/03/2010 03:33 AM, Joshua J. Kugler wrote:
>>> So, in my ongoing saga getting suds working with MS Exchange 2007
>>> (which I'm sure you'll hear a lot more about before I'm done :)
>>> ), I hit an a couple interesting snags.
>>>
>>> python-ntlm seems to time out against the server when doing POST
>>> requests (but get requests seem fine). But that's not the
>>> current issue.
>>>
>>> When one of my requests went through, I got back this message:
>>>
>>> suds.WebFault: Server raised fault: 'Server was unable to process
>>> request. ---> Input message does not conform to Simple SOAP
>>> Binding Profile Version 1.0. Requirement R1012: A MESSAGE MUST
>>> serialize the envelope using either UTF-8 or UTF-16 character
>>> encoding.'
>>>
>>> I thought Suds encoded everything in UTF-8 be default. The debug
>>> output is below:
>>>
>>> DEBUG:suds.client:sending to (
https://myserver/EWS/exchange.asmx)
>>> message:
>>> <SOAP-ENV:Envelope
>>>
xmlns:ns0="http://schemas.microsoft.com/exchange/services/2006/ty
>>>pe s"
xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/"
>>>
xmlns:ns2="http://schemas.microsoft.com/exchange/services/2006/me
>>>ss ages"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>>>
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
>>> <SOAP-ENV:Header/>
>>> <ns1:Body>
>>> <ns2:GetFolder>
>>> <ns2:FolderShape>
>>> <ns0:BaseShape>Default</ns0:BaseShape>
>>> </ns2:FolderShape>
>>> <ns2:FolderIds>
>>> <ns0:DistinguishedFolderId Id="inbox"/>
>>> </ns2:FolderIds>
>>> </ns2:GetFolder>
>>> </ns1:Body>
>>> </SOAP-ENV:Envelope>
>>> DEBUG:suds.client:headers = {'SOAPAction':
>>>
u'"http://schemas.microsoft.com/exchange/services/2006/messages/G
>>>et Folder"', 'Content-Type': 'text/xml'}
>>>
>>> Should the fact that it's UTF-8 encoded be in the headers or
>>> request somewhere like so:
>>
>> Suds probably should be setting the content-type http header as
>> described in ticket 251.
>> (
https://fedorahosted.org/suds/ticket/251). Can you try and let me
>> know if this fixes your problem?
>
> Weird, I use this code:
>
> headers = {'Content-Type': 'text/xml; charset=utf-8'}
> c =
> suds.client.Client('file:///home/jkugler/crc/local-tools/services.w
>sdl', transport=ntlm,
> headers=headers)
>
> And Suds still tells me it's only sending 'text/xml' as the type.
> Leading to the same error.
>
> DEBUG:suds.client:sending to (
https://myserver/ews/exchange.asmx)
> message:
> <SOAP-ENV:Envelope
>
xmlns:ns0="http://schemas.microsoft.com/exchange/services/2006/type
>s"
xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/"
>
xmlns:ns2="http://schemas.microsoft.com/exchange/services/2006/mess
>ages"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
> <SOAP-ENV:Header/>
> <ns1:Body>
> <ns2:GetFolder>
> <ns2:FolderShape>
> <ns0:BaseShape>Default</ns0:BaseShape>
> </ns2:FolderShape>
> <ns2:FolderIds>
> <ns0:DistinguishedFolderId Id="inbox"/>
> </ns2:FolderIds>
> </ns2:GetFolder>
> </ns1:Body>
> </SOAP-ENV:Envelope>
> DEBUG:suds.client:headers = {'SOAPAction':
>
u'"http://schemas.microsoft.com/exchange/services/2006/messages/Get
>Folder"', 'Content-Type': 'text/xml'}
>
> In the failed message back from the server, it starts:
>
> <?xml version="1.0" encoding="utf-8"?>
>
> Is that what needs to be added?
Yup, this should probably be added too. Most servers don't seem to
care but ... Anyway, In r671, (0.4 beta) I added "<?xml version="1.0"
encoding="utf-8"?>" and updated the default http headers so that
content-type="text/xml; charset=utf-8" All my regression tests
against my (and public) servers pass so it seems safe to make these
changes. Hope this helps.
Thanks! That seems to get me further, but now I'm hitting another
error:
<h1>Bad Request (Invalid Verb)</h1>
which generates this traceback:
Traceback (most recent call last):
File "./get_mail.py", line 39, in <module>
{'_Id':'inbox'}})
File "build/bdist.linux-i686/egg/suds/client.py", line 539, in
__call__
File "build/bdist.linux-i686/egg/suds/client.py", line 598, in invoke
File "build/bdist.linux-i686/egg/suds/client.py", line 627, in send
File "build/bdist.linux-i686/egg/suds/client.py", line 659, in
succeeded
File "build/bdist.linux-i686/egg/suds/bindings/binding.py", line 146,
in get_reply
AttributeError: 'NoneType' object has no attribute 'promotePrefixes'
I don't have time to troubleshoot right now, but I will later, and will
post a full code samle.
j
--
Joshua Kugler
Part-Time System Admin/Programmer
http://www.eeinternet.com
PGP Key:
http://pgp.mit.edu/ ID 0x73B13B6A