简体   繁体   English

Exchange 2013 EWS PHP - FindItem限制错误

[英]Exchange 2013 EWS PHP - FindItem Restriction error

I'm working on an webapplication which connects to Microsoft Exchange 2013. The problem is that if i'm using 'Restriction' on 'FindItem', I recieve an error. 我正在开发一个连接到Microsoft Exchange 2013的web应用程序。问题是如果我在'FindItem'上使用'Restriction',我会收到一个错误。

This code works, but without restriction: 此代码有效,但没有限制:

<?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>

This code doesn't work, with restriction: 此代码不起作用,但有限制:

<?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>

And this is the error I get: 这是我得到的错误:

<?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>

Does someone now a solution for this problem? 有人现在可以解决这个问题吗?

Try putting ParentFolderIds after the Restriction. 尝试在限制后放置ParentFolderIds。 The following code works for me, but if I put ParentFolderIds before Restriction, it fails. 以下代码适用于我,但如果我在限制之前放置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="sadie@contoso.com" />
            </t:FieldURIOrConstant>
          </t:IsEqualTo>
          <t:IsEqualTo>
            <t:FieldURI FieldURI="message:Sender" />
            <t:FieldURIOrConstant>
              <t:Constant Value="sadie@contoso.com" />
            </t:FieldURIOrConstant>
          </t:IsEqualTo>
        </t:Or>
      </m:Restriction>
    </m:FindItem>
  </soap:Body>
</soap:Envelope>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM