当前位置 : 主页 > 网页制作 > xml >

Exchange:使用XML请求在EWS对话中查找项目?

来源:互联网 收集:自由互联 发布时间:2021-06-13
我正在尝试使用Exchange EWS 2010查找对话中的项目,无论他们在哪个文件夹中.我不想在单个文件夹中获取所有conversationId的列表.我想逐个查询对话. 我在Android上这样做,并且已经为其他EWS请
我正在尝试使用Exchange EWS 2010查找对话中的项目,无论他们在哪个文件夹中.我不想在单个文件夹中获取所有conversationId的列表.我想逐个查询对话.

我在Android上这样做,并且已经为其他EWS请求发送XML soap请求.

我的问题是:

如果是ConversationId,XML应如何格式化以在单个对话中检索项目?

我已经尝试使用FindItem with Restriction和QueryString,但似乎都没有给出任何结果.

有办法吗?我熟悉“FindConversations”操作,但它似乎返回文件夹中所有会话的所有消息.我想要特定对话的消息.

以下是我尝试过的两个示例XML请求.

尝试使用QueryString:

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
               xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" 
               xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" 
               xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Header>
    <t:RequestServerVersion Version="Exchange2010_SP1" />
  </soap:Header>
  <soap:Body>
    <m:FindItem Traversal="Shallow">
      <m:ItemShape>
        <t:BaseShape>AllProperties</t:BaseShape>
        <t:AdditionalProperties>
          <t:FieldURI FieldURI="item:Subject" />
          <t:FieldURI FieldURI="item:DateTimeReceived" />
          <t:FieldURI FieldURI="message:From" />
        </t:AdditionalProperties>
      </m:ItemShape>
      <m:IndexedPageItemView MaxEntriesReturned="10" Offset="0" BasePoint="Beginning" />
      <m:ParentFolderIds>
          <t:DistinguishedFolderId Id="inbox"/>
      </m:ParentFolderIds>
      <m:QueryString>item:ConversationId:AAQkADg5MmFjNTViLTYwODUtNGNmYi04MzhjLTczZTdkOTZmYjllNwAQAA/J3OiwUmlBntyd9PhAWBM=</m:QueryString>
    </m:FindItem>
  </soap:Body>
</soap:Envelope>

尝试使用限制:

<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"      
     xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages"
     xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types"
     xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Header>
    <t:RequestServerVersion Version="Exchange2010_SP1" />
  </soap:Header>
  <soap:Body>
    <m:FindItem Traversal="Shallow">
      <m:ItemShape>
        <t:BaseShape>IdOnly</t:BaseShape>
      </m:ItemShape>
      <m:IndexedPageItemView MaxEntriesReturned="50" Offset="0" BasePoint="Beginning" />
      <m:Restriction>
          <t:IsEqualTo>
            <t:FieldURI FieldURI="item:ConversationId" />
            <t:FieldURIOrConstant>
              <t:Constant Value="AAQkADg5MmFjNTViLTYwODUtNGNmYi04MzhjLTczZTdkOTZmYjllNwAQAA/J3OiwUmlBntyd9PhAWBM="/>
            </t:FieldURIOrConstant>
          </t:IsEqualTo>
      </m:Restriction>
      <m:SortOrder>
        <t:FieldOrder Order="Descending">
          <t:FieldURI FieldURI="item:DateTimeReceived" />
        </t:FieldOrder>
      </m:SortOrder>
      <m:ParentFolderIds>
        <t:DistinguishedFolderId Id="inbox" />
      </m:ParentFolderIds>
    </m:FindItem>
  </soap:Body>
</soap:Envelope>
我能够根据ConversationIndex搜索消息.我在Java / Android上使用“JWebServices for Exchange”API.您必须使用带限制的findItem方法并使用PR_CONVERSATION_INDEX字段(标准MAPI属性).代码如下:

IsEqualTo restriction = new IsEqualTo(MapiPropertyTag.PR_CONVERSATION_INDEX, "AA3OiwUmlB...");

        FindItemResponse response = service.findItem(StandardFolder.INBOX, restriction);
网友评论