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&q...
xmlns:m="http://schemas.microsoft.com/exchange/services/2006/message...
<s:Header>%s</s:Header>
<s:Body>%s</s:Body>
</s:Envelope>''' % (header, myelement)
c.service.MyFunction(__inject={'msg':xml})
Thanks,
Erik