FindItems(电子邮件)限于日期

时间:2013-11-24 10:31:23

标签: java cxf exchangewebservices

我尝试根据“已收到”或“已发送”日期搜索电子邮件。

这是我的要求:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Header>
    <MailboxCulture xmlns:ns2="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns="http://schemas.microsoft.com/exchange/services/2006/types">de-AT</MailboxCulture>
    <RequestServerVersion xmlns:ns2="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns="http://schemas.microsoft.com/exchange/services/2006/types" Version="Exchange2013" />
  </soap:Header>
  <soap:Body>
    <ns2:FindItem xmlns="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:ns2="http://schemas.microsoft.com/exchange/services/2006/messages" Traversal="Shallow">
      <ns2:ItemShape>
        <BaseShape>IdOnly</BaseShape>
      </ns2:ItemShape>
      <ns2:Restriction>
        <And>
          <IsEqualTo>
            <Path xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="PathToUnindexedFieldType" FieldURI="item:ItemClass" />
            <FieldURIOrConstant>
              <Constant Value="IPM.NOTE" />
            </FieldURIOrConstant>
          </IsEqualTo>
          <IsGreaterThanOrEqualTo>
            <Path xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="PathToUnindexedFieldType" FieldURI="item:DateTimeReceived" />
            <FieldURIOrConstant>
              <Constant Value="2013-03-13T09:00:00Z" />
            </FieldURIOrConstant>
          </IsGreaterThanOrEqualTo>
          <IsLessThanOrEqualTo>
            <Path xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="PathToUnindexedFieldType" FieldURI="item:DateTimeReceived" />
            <FieldURIOrConstant>
              <Constant Value="2013-12-13T09:00:00Z" />
            </FieldURIOrConstant>
          </IsLessThanOrEqualTo>
        </And>
      </ns2:Restriction>
      <ns2:ParentFolderIds>
        <DistinguishedFolderId Id="inbox" />
      </ns2:ParentFolderIds>
    </ns2:FindItem>
  </soap:Body>
</soap:Envelope>

但我回过头来看错误:

WARNING: Interceptor for {http://schemas.microsoft.com/exchange/services/2006/messages}ExchangeService#{http://schemas.microsoft.com/exchange/services/2006/messages}FindItem has thrown exception, unwinding now
org.apache.cxf.interceptor.Fault: Could not send Message.
..
Caused by: org.apache.cxf.transport.http.HTTPException: HTTP response '503: Service Unavailable' when communicating with https://mail.rbes.local/ews/exchange.asmx

如果我省略了限制,我会收到有效回复。

任何人都可以帮助我?

其他请求相同的错误:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Header>
    <MailboxCulture xmlns:ns2="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns="http://schemas.microsoft.com/exchange/services/2006/types">de-AT</MailboxCulture>
    <RequestServerVersion xmlns:ns2="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns="http://schemas.microsoft.com/exchange/services/2006/types" Version="Exchange2013" />
  </soap:Header>
  <soap:Body>
    <ns2:FindItem xmlns="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:ns2="http://schemas.microsoft.com/exchange/services/2006/messages" Traversal="Shallow">
        <ns2:ItemShape>
            <BaseShape>IdOnly</BaseShape>
        </ns2:ItemShape>
        <ns2:Restriction>
            <IsLessThanOrEqualTo>
                <Path xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="PathToUnindexedFieldType" FieldURI="item:DateTimeReceived" />
                <FieldURIOrConstant>
                    <Constant Value="2013-12-13T09:00:00Z" />
                </FieldURIOrConstant>
            </IsLessThanOrEqualTo>
        </ns2:Restriction>
        <ns2:ParentFolderIds>
            <DistinguishedFolderId Id="inbox" />
        </ns2:ParentFolderIds>
    </ns2:FindItem>
  </soap:Body>
</soap:Envelope>

1 个答案:

答案 0 :(得分:0)

使用JWebServices for Exchange发送请求有效请求生成为:

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"  xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
<soap:Header>
  <t:RequestServerVersion Version="Exchange2013"/>
</soap:Header>
<soap:Body>
  <FindItem Traversal="Shallow" xmlns="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
    <ItemShape>
      <t:BaseShape>IdOnly
      </t:BaseShape>
    </ItemShape>
    <Restriction>
      <t:And>
        <t:IsEqualTo>
          <t:FieldURI FieldURI="item:ItemClass" />
          <t:FieldURIOrConstant>
             <t:Constant Value="IPM.Note"/>
          </t:FieldURIOrConstant>
        </t:IsEqualTo>
        <t:IsGreaterThanOrEqualTo>
          <t:FieldURI FieldURI="item:DateTimeReceived" />
          <t:FieldURIOrConstant>
             <t:Constant Value="2013-03-12T23:00:00Z"/>
          </t:FieldURIOrConstant>
        </t:IsGreaterThanOrEqualTo>
        <t:IsLessThanOrEqualTo>
          <t:FieldURI FieldURI="item:DateTimeReceived" />
          <t:FieldURIOrConstant>
             <t:Constant Value="2013-03-12T23:00:00Z"/>
          </t:FieldURIOrConstant>
        </t:IsLessThanOrEqualTo>
      </t:And>
    </Restriction>
    <ParentFolderIds>
      <t:DistinguishedFolderId Id="inbox">
      </t:DistinguishedFolderId>
    </ParentFolderIds>
  </FindItem>
</soap:Body>
</soap:Envelope>