GetEvents 操作

请求订阅客户端使用 GetEvents 操作从客户端访问服务器请求通知。 GetEvents 操作响应返回自上次通知以来邮箱中发生的项目和事件数组。

重要

DeleteUserConfiguration 操作将触发事件通知系统的移动事件。 用户配置对象将移动到转储器。

注意

对日历项的更改可能会导致生成多个事件。 这些事件是在邮箱中创建临时项目、在正常日历操作中更改忙/闲数据存储项目的结果,或者两者兼有。 项类“IPM”的事件。Web 服务客户端应忽略 SchedulePlus.FreeBusy.BinaryData”。 这些临时项在创建后将其删除;因此,如果尝试检索这些项目,将返回一个错误,指出找不到该项。

GetEvents 请求示例

说明

以下示例演示如何请求与订阅标识符和水印标识的订阅关联的事件和项。

代码

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
  xmlns:t="https://schemas.microsoft.com/exchange/services/2006/types">
  <soap:Body>
    <GetEvents xmlns="https://schemas.microsoft.com/exchange/services/2006/messages">
      <SubscriptionId>f6bc657d-dde1-4f94-952d-143b95d6483d</SubscriptionId>
      <Watermark>AAAAAMAGAAAAAAAAAQ==</Watermark>
    </GetEvents>
  </soap:Body>
</soap:Envelope>

GetEvents 请求元素

请求中使用以下元素:

成功的 GetEvents 响应示例

说明

下面的响应示例显示自上次通知请求发送到服务器以来存在两封新邮件的通知。

代码

<?xml version="1.0" encoding="utf-8" ?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" 
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
               xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <soap:Header>
    <t:ServerVersionInfo MajorVersion="8" MinorVersion="0" MajorBuildNumber="628" MinorBuildNumber="0" 
                         xmlns:t="https://schemas.microsoft.com/exchange/services/2006/types" />
  </soap:Header>
  <soap:Body>
    <GetEventsResponse xmlns:m="https://schemas.microsoft.com/exchange/services/2006/messages" 
                       xmlns:t="https://schemas.microsoft.com/exchange/services/2006/types" 
                       xmlns="https://schemas.microsoft.com/exchange/services/2006/messages">
      <m:ResponseMessages>
        <m:GetEventsResponseMessage ResponseClass="Success">
          <m:ResponseCode>NoError</m:ResponseCode>
          <m:Notification>
            <t:SubscriptionId>f6bc657d-dde1-4f94-952d-143b95d6483d</t:SubscriptionId>
            <t:PreviousWatermark>AAAAAMAGAAAAAAAAAQ==</t:PreviousWatermark>
            <t:MoreEvents>false</t:MoreEvents>
            <t:NewMailEvent>
              <t:Watermark>AAAAAM4GAAAAAAAAAQ==</t:Watermark>
              <t:TimeStamp>2006-08-22T00:36:29Z</t:TimeStamp>
              <t:ItemId Id="AQApAHR" ChangeKey="CQAAAA==" />
              <t:ParentFolderId Id="AQApAH" ChangeKey="AQAAAA==" />
            </t:NewMailEvent>
            <t:NewMailEvent>
              <t:Watermark>AAAAAOQGAAAAAAAAAQ==</t:Watermark>
              <t:TimeStamp>2006-08-22T01:00:50Z</t:TimeStamp>
              <t:ItemId Id="AQApAHRw" ChangeKey="CQAAAA==" />
              <t:ParentFolderId Id="AQApAH" ChangeKey="AQAAAA==" />
            </t:NewMailEvent>
          </m:Notification>
        </m:GetEventsResponseMessage>
      </m:ResponseMessages>
    </GetEventsResponse>
  </soap:Body>
</soap:Envelope>

Comments

注意

项目和文件夹标识符已缩短,以保持可读性。

GetEvents 响应元素

响应中使用以下元素:

若要查找 GetEvents 操作响应消息的其他选项,请浏览架构层次结构。 从 Notification 元素开始。

GetEvents 错误响应示例

说明

以下示例显示了 对 GetEvents 请求的错误响应。

代码

<?xml version="1.0" encoding="utf-8" ?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" 
                 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
                 xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <soap:Header>
    <t:ServerVersionInfo MajorVersion="8" MinorVersion="0" MajorBuildNumber="628" MinorBuildNumber="0" 
                         xmlns:t="https://schemas.microsoft.com/exchange/services/2006/types" />
  </soap:Header>
  <soap:Body>
    <GetEventsResponse xmlns:m="https://schemas.microsoft.com/exchange/services/2006/messages" 
                         xmlns:t="https://schemas.microsoft.com/exchange/services/2006/types" 
                         xmlns="https://schemas.microsoft.com/exchange/services/2006/messages">
      <m:ResponseMessages>
        <m:GetEventsResponseMessage ResponseClass="Error">
          <m:MessageText>Access is denied. Only the subscription owner may access the subscription.</m:MessageText>
          <m:ResponseCode>ErrorSubscriptionAccessDenied</m:ResponseCode>
          <m:DescriptiveLinkKey>0</m:DescriptiveLinkKey>
        </m:GetEventsResponseMessage>
      </m:ResponseMessages>
    </GetEventsResponse>
  </soap:Body>
</soap:Envelope>

备注

处理 GetEvents 请求时,客户端访问服务器执行以下步骤:

  1. 请求的 SubscriptionID 被确认为客户端访问服务器上托管的有效订阅。 否则, GetEvents 调用将失败。

  2. 请求的经过身份验证的用户的 SMTP 地址与创建订阅的用户的 SMTP 地址进行比较。 如果不匹配, GetEvents 请求将失败。

  3. 在订阅队列中查询等待发送到客户端的事件。 如果队列不为空,则队列中的前 50 个事件将从队列中拉取并编码为通知。

  4. 如果在队列中找不到任何事件,则会生成 StatusEvent 并将其编码为通知响应。

  5. 通知响应将返回到客户端。

  6. 通知中包含的事件将从订阅队列中删除,并且订阅的客户端访问服务器本地最后一个水印设置为返回的最后一个事件的水印。

  7. 订阅的超时计时器重置。

另请参阅

订阅操作

Unsubscribe 操作

使用请求订阅