Hi All,
I am stuck. It seems I can not talk to my exchange server. Here is some code along with the error message:
ntlm = WindowsHttpAuthenticated(username='USER_NAME',password='XXX') c = Client(url,transport=ntlm)
#version = Element('t:RequestServerVersion') #version.set('Version', 'Exchange2010') #c.set_options(soapheaders=version)
x = c.service.GetRoomLists() print x
attr = c.service.GetRoomLists() File "build/bdist.macosx-10.6-universal/egg/suds/client.py", line 539, in __call__ File "build/bdist.macosx-10.6-universal/egg/suds/client.py", line 598, in invoke File "build/bdist.macosx-10.6-universal/egg/suds/client.py", line 633, in send File "build/bdist.macosx-10.6-universal/egg/suds/client.py", line 684, in failed File "build/bdist.macosx-10.6-universal/egg/suds/bindings/binding.py", line 238, in get_fault suds.WebFault: Server raised fault: 'The request is valid but does not specify the correct server version in the RequestServerVersion SOAP header. Ensure that the RequestServerVersion SOAP header is set with the correct RequestServerVersionValue.'
If I uncomment the t:RequestServerVersion section, this is the error I get:
attr = c.service.GetRoomLists() File "build/bdist.macosx-10.6-universal/egg/suds/client.py", line 539, in __call__ File "build/bdist.macosx-10.6-universal/egg/suds/client.py", line 598, in invoke File "build/bdist.macosx-10.6-universal/egg/suds/client.py", line 633, in send File "build/bdist.macosx-10.6-universal/egg/suds/client.py", line 690, in failed Exception: (400, u'Bad Request')
Any help would be greatly appreciated!
- Jared
Hi Jared,
Den 21/07/2010 kl. 02.46 skrev Jared Eckersley:
Hi All,
I am stuck. It seems I can not talk to my exchange server. Here is some code along with the error message:
ntlm = WindowsHttpAuthenticated(username='USER_NAME',password='XXX') c = Client(url,transport=ntlm)
#version = Element('t:RequestServerVersion') #version.set('Version', 'Exchange2010') #c.set_options(soapheaders=version)
x = c.service.GetRoomLists() print x
Look up in your types.xsd which version info it has:
from xml.etree import ElementTree filename = '/path/to/types.xsd' version = ElementTree.parse(filename).getroot().attrib['version'] print version
Use this version to create your t:RequestServerVersion header element.
That said, you're not going to get far using the service factory methods (due to bugs in both Suds and EWS). For more advanced service requests, you need to build the raw XML and inject it. It's not much more of a hassle, though. You just don't get the schema validation Suds does: from suds.sax.element import Element myelement = Element('t:MyElement').setText('Hello EWS') header = Element('t:RequestServerVersion') header.set('Version', version) xml = '''<?xml version="1.0" encoding="UTF-8"?> <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages%22%3E <s:Header>%s</s:Header> <s:Body>%s</s:Body> </s:Envelope>''' % (header, myelement) c.service.MyFunction(__inject={'msg':xml})
Thanks, Erik