2014-01-21 89 views
0

我正在研究连接到Microsoft Exchange 2013的web应用程序。 问题是,如果我在'FindItem'上使用'限制',我收到一个错误。Exchange 2013 EWS PHP - FindItem限制错误

此代码的工作,但没有限制:

<?xml version="1.0" encoding="UTF-8"?> 
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:ns2="http://schemas.microsoft.com/exchange/services/2006/messages"> 
    <SOAP-ENV:Body> 
     <ns2:FindItem xmlns="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" Traversal="Shallow"> 
      <ns2:ItemShape> 
       <ns1:BaseShape>AllProperties</ns1:BaseShape> 
      </ns2:ItemShape> 
      <ns2:IndexedPageItemView MaxEntriesReturned="50" Offset="0" BasePoint="Beginning"/> 
      <ns2:ParentFolderIds> 
       <ns1:FolderId Id="(myFolderID)"/> 
      </ns2:ParentFolderIds> 
     </ns2:FindItem> 
    </SOAP-ENV:Body> 
</SOAP-ENV:Envelope> 

此代码不能正常工作,对于限制:

<?xml version="1.0" encoding="UTF-8"?> 
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:ns2="http://schemas.microsoft.com/exchange/services/2006/messages"> 
    <SOAP-ENV:Body> 
     <ns2:FindItem xmlns="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" Traversal="Shallow"> 
      <ns2:ItemShape> 
       <ns1:BaseShape>AllProperties</ns1:BaseShape> 
      </ns2:ItemShape> 
      <ns2:IndexedPageItemView MaxEntriesReturned="50" Offset="0" BasePoint="Beginning"/> 
      <ns2:ParentFolderIds> 
       <ns1:FolderId Id="(myFolderID)"/> 
      </ns2:ParentFolderIds> 
      <ns2:Restriction> 
       <Or> 
        <IsEqualTo> 
         <FieldURI FieldURI="message:From" /> 
         <FieldURIOrConstant> 
          <Constant Value="(searchEmailAddress)" /> 
         </FieldURIOrConstant> 
        </IsEqualTo> 
        <IsEqualTo> 
         <FieldURI FieldURI="message:Sender" /> 
         <FieldURIOrConstant> 
          <Constant Value="(searchEmailAddress)" /> 
         </FieldURIOrConstant> 
        </IsEqualTo> 
       </Or> 
      </ns2:Restriction> 
     </ns2:FindItem> 
    </SOAP-ENV:Body> 
</SOAP-ENV:Envelope> 

这是我的错误:

<?xml version="1.0" encoding="utf-8"?> 
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> 
    <s:Body> 
     <s:Fault> 
      <faultcode xmlns:a="http://schemas.microsoft.com/exchange/services/2006/types">a:ErrorSchemaValidation</faultcode> 
      <faultstring xml:lang="en-US">The request failed schema validation: The element 'FindItem' in namespace 'http://schemas.microsoft.com/exchange/services/2006/messages' has invalid child element 'Restriction' in namespace 'http://schemas.microsoft.com/exchange/services/2006/messages'.</faultstring> 
      <detail> 
       <e:ResponseCode xmlns:e="http://schemas.microsoft.com/exchange/services/2006/errors">ErrorSchemaValidation</e:ResponseCode> 
       <e:Message xmlns:e="http://schemas.microsoft.com/exchange/services/2006/errors">The request failed schema validation.</e:Message> 
       <t:MessageXml xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types"> 
        <t:LineNumber>9</t:LineNumber> 
        <t:LinePosition>5</t:LinePosition> 
        <t:Violation>The element 'FindItem' in namespace 'http://schemas.microsoft.com/exchange/services/2006/messages' has invalid child element 'Restriction' in namespace 'http://schemas.microsoft.com/exchange/services/2006/messages'.</t:Violation> 
       </t:MessageXml> 
      </detail> 
     </s:Fault> 
    </s:Body> 
</s:Envelope> 

现在是否有人为此问题提供解决方案?

回答

2

尝试在限制后放置ParentFolderIds。以下代码适用于我,但如果在限制之前放置ParentFolderIds,则会失败。

<?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="Exchange2013" /> 
    </soap:Header> 
    <soap:Body> 
    <m:FindItem Traversal="Shallow"> 
     <m:ItemShape> 
     <t:BaseShape>AllProperties</t:BaseShape> 
     </m:ItemShape> 
     <m:IndexedPageItemView MaxEntriesReturned="50" Offset="0" BasePoint="Beginning" /> 
      <m:ParentFolderIds> 
     <t:FolderId Id="..." /> 
     </m:ParentFolderIds> 
<m:Restriction> 
     <t:Or> 
      <t:IsEqualTo > 
      <t:FieldURI FieldURI="message:From" /> 
      <t:FieldURIOrConstant> 
       <t:Constant Value="[email protected]" /> 
      </t:FieldURIOrConstant> 
      </t:IsEqualTo> 
      <t:IsEqualTo> 
      <t:FieldURI FieldURI="message:Sender" /> 
      <t:FieldURIOrConstant> 
       <t:Constant Value="[email protected]" /> 
      </t:FieldURIOrConstant> 
      </t:IsEqualTo> 
     </t:Or> 
     </m:Restriction> 
    </m:FindItem> 
    </soap:Body> 
</soap:Envelope> 
+0

你太棒了!这是正确的答案,在'Restriction'使其工作后放置'ParentFolderIds'。谢谢。 –