【发布时间】:2016-10-17 12:33:43
【问题描述】:
我正在尝试使用 suds 库在 Python 中检索 Exchange 日历事件。
我能够读取 FreeBusyResponse 数据,但我无法成功检索实际的日历事件。
soap 请求看起来不错:
<?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>
代码中的相关部分:
find_item_request = client.factory.create('FindItemType')
shape_types = client.factory.create('ns1:DefaultShapeNamesType')
shape_type = client.factory.create('ns1:ItemResponseShapeType')
shape_type.BaseShape = 'Default'
find_item_request.ItemShape = shape_type
find_item_request._Traversal = 'Shallow'
mailbox = Element('ns1:Mailbox')
emailaddress = Element('ns1:EmailAddress').setText('dries@myhost.be')
mailbox.append(emailaddress)
folder_id_type = client.factory.create('ns1:DistinguishedFolderId')
folder_id_type.Mailbox = mailbox
folder_id_type._Id = 'calendar'
folder_ids = client.factory.create('ns1:NonEmptyArrayOfBaseFolderIdsType')
folder_ids.DistinguishedFolderId = folder_id_type
find_item_request.ParentFolderIds = folder_ids
calendar_view = client.factory.create('ns1:CalendarViewType')
calendar_view._StartDate = start
calendar_view._EndDate = end
find_item_request.CalendarView = calendar_view
client.service.FindItem.method.soap.input.body.wrapped = False
try:
find_item_response = client.service.FindItem(find_item_request)
except WebFault as e:
raise e
msg = result.FindItemResponseMessage
我应该使用 CalendarView 以外的东西吗?
【问题讨论】:
标签: python exchangewebservices suds