我正在尝试使用suds库在Python中检索Exchange日历事件。
我能够阅读FreeBusyResponse数据,但我没有成功检索实际的日历事件。
肥皂请求似乎很好:
<p>top</p>
<p class="borders">Aliquam et enim congue, luctus nulla vel...</p>
<p>bottom</p>
代码中的Relvant部分:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
xmlns:ns0="http://schemas.microsoft.com/exchange/services/2006/types"
xmlns:ns1="http://schemas.microsoft.com/exchange/services/2006/messages"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header>
<t:RequestServerVersion Version="Exchange2010_SP1"/>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<ns1:FindItem Traversal="Shallow">
<ns1:ItemShape>
<ns0:BaseShape>Default</ns0:BaseShape>
</ns1:ItemShape>
<ns1:CalendarView xsi:type="ns0:CalendarViewType" StartDate="2016-10-17T14:10:41.620151+01:00" EndDate="2016-10-17T14:10:41.620176+01:00"/>
<ns1:ParentFolderIds>
<ns0:DistinguishedFolderId xsi:type="ns0:DistinguishedFolderIdType" Id="calendar">
<ns0:Mailbox>
<ns0:EmailAddress>dries@myhost.be</ns0:EmailAddress>
</ns0:Mailbox>
</ns0:DistinguishedFolderId>
</ns1:ParentFolderIds>
</ns1:FindItem>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
我应该使用除CalendarView以外的其他内容吗?
答案 0 :(得分:0)
我找到了以下解决方案:
import time
import datetime
import pytz
from suds.client import WebFault
from suds.client import Client
from suds.sax.element import Element
from suds.transport.http import HttpTransport
from suds.sudsobject import asdict
< auth and transport comes here >
# Todo: fix timezones displayed in suds output.
start = datetime.datetime.now(pytz.timezone('Europe/Brussels')).isoformat()
end = datetime.datetime.now(pytz.timezone('Europe/Brussels')).isoformat()
fi = client.factory.create('FindItem')
fi.ItemShape.BaseShape = 'AllProperties'
fi.ParentFolderIds.DistinguishedFolderId = client.factory.create('t:DistinguishedFolderIdType')
fi.ParentFolderIds.DistinguishedFolderId._Id = 'calendar'
fi._Traversal = 'Shallow'
calendar_view = client.factory.create('CalendarView')
calendar_view._StartDate = start
calendar_view._EndDate = end
fi.CalendarView = calendar_view
#client.service.FindItem.method.soap.input.body.wrapped = False
try:
response = client.service.FindItem(**asdict(fi))
print response
except WebFault as e:
raise e