'Traversal' 属性未声明。在 GetItem EWS 请求中

The 'Traversal' attribute is not declared. In GetItem EWS request

我有 EWS soap 请求:

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages"
    xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
    <soap:Header>
        <t:ExchangeImpersonation>
            <t:ConnectingSID>
                <t:PrincipalName>room1@exch2010.local</t:PrincipalName>
            </t:ConnectingSID>
        </t:ExchangeImpersonation>
    </soap:Header>
    <soap:Body>
        <m:GetItem Traversal="Shallow">
            <m:ItemShape>
                <t:BaseShape>IdOnly</t:BaseShape>
                <t:AdditionalProperties>
                    <t:FieldURI FieldURI="item:Subject"></t:FieldURI>
                    <t:FieldURI FieldURI="calendar:Start"></t:FieldURI>
                    <t:FieldURI FieldURI="calendar:End"></t:FieldURI>
                    <t:FieldURI FieldURI="calendar:Location"></t:FieldURI>
                    <t:FieldURI FieldURI="calendar:Organizer"></t:FieldURI>
                    <t:FieldURI FieldURI="item:Body"></t:FieldURI>
                    <t:FieldURI FieldURI="item:TextBody"></t:FieldURI>
                </t:AdditionalProperties>
            </m:ItemShape>
            <m:ItemIds>
                <t:ItemId Id="AAAUAHJvb20xQGV4Y2gyMDEwLmxvY2FsAEYAAAAAALp73pDts6BGkBAHp2xunxIHAOLiLPCbqYNEl0bu9R23VJMAAAAW2OQAAOLiLPCbqYNEl0bu9R23VJMAAAAXKY8AAA==" ChangeKey="DwAAAA=="></t:ItemId>
            </m:ItemIds>
        </m:GetItem>
    </soap:Body>
</soap: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 'Traversal' attribute is not declared.</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>16</t:LineNumber>
                        <t:LinePosition>20</t:LinePosition>
                        <t:Violation>The 'Traversal' attribute is not declared.</t:Violation>
                    </t:MessageXml>
                </detail>
            </s:Fault>
        </s:Body>
    </s:Envelope>

为什么会失败?

类似的请求

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages"
    xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
    <soap:Header>
        <t:ExchangeImpersonation>
            <t:ConnectingSID>
                <t:PrincipalName>room1@exch2010.local</t:PrincipalName>
            </t:ConnectingSID>
        </t:ExchangeImpersonation>
    </soap:Header>
    <soap:Body>
        <m:FindItem Traversal="Shallow">
            <m:ItemShape>
                <t:BaseShape>IdOnly</t:BaseShape>
                <t:AdditionalProperties>
                    <t:FieldURI FieldURI="item:Subject"></t:FieldURI>
                    <t:FieldURI FieldURI="calendar:Start"></t:FieldURI>
                    <t:FieldURI FieldURI="calendar:End"></t:FieldURI>
                    <t:FieldURI FieldURI="calendar:Location"></t:FieldURI>
                </t:AdditionalProperties>
            </m:ItemShape>
            <m:CalendarView StartDate="2016-05-30T11:08:48" EndDate="2016-12-31T11:08:48"></m:CalendarView>
            <m:ParentFolderIds>
                <t:FolderId Id="AAAUAHJvb20xQGV4Y2gyMDEwLmxvY2FsAC4AAAAAALp73pDts6BGkBAHp2xunxIBAOLiLPCbqYNEl0bu9R23VJMAAAAW2OQAAA==" ChangeKey="AgAAABYAAADi4izwm6mDRJdG7vUdt1STAAAAFtkD"></t:FolderId>
            </m:ParentFolderIds>
        </m:FindItem>
    </soap:Body>
</soap:Envelope> 

完美运行

编辑 1:

我删除了遍历属性,然后出现错误:

<?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 'FieldURI' attribute is invalid - The value 'item:TextBody' is invalid according to its datatype 'http://schemas.microsoft.com/exchange/services/2006/types:UnindexedFieldURIType' - The Enumeration constraint failed.</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>3</t:LineNumber>
                    <t:LinePosition>649</t:LinePosition>
                    <t:Violation>The 'FieldURI' attribute is invalid - The value 'item:TextBody' is invalid according to its datatype 'http://schemas.microsoft.com/exchange/services/2006/types:UnindexedFieldURIType' - The Enumeration constraint failed.</t:Violation>
                </t:MessageXml>
            </detail>
        </s:Fault>
    </s:Body>
</s:Envelope>

然后我删除了最后一个Additional 属性

 <t:FieldURI FieldURI="item:TextBody"></t:FieldURI>

终于得到了这个错误。

<?xml version="1.0" encoding="utf-8"?>
<s:Envelope
    xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
    <s:Header>
        <h:ServerVersionInfo MajorVersion="14" MinorVersion="3" MajorBuildNumber="123" MinorBuildNumber="3" Version="Exchange2010_SP2"
            xmlns:h="http://schemas.microsoft.com/exchange/services/2006/types"
            xmlns="http://schemas.microsoft.com/exchange/services/2006/types"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xmlns:xsd="http://www.w3.org/2001/XMLSchema"/>
        </s:Header>
        <s:Body
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xmlns:xsd="http://www.w3.org/2001/XMLSchema">
            <m:GetItemResponse
                xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages"
                xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
                <m:ResponseMessages>
                    <m:GetItemResponseMessage ResponseClass="Error">
                        <m:MessageText>The EWS Id is in EwsLegacyId format which is not supported by the Exchange version specified by your request. Please use the ConvertId method to convert from EwsLegacyId to EwsId format.</m:MessageText>
                        <m:ResponseCode>ErrorInvalidIdMalformedEwsLegacyIdFormat</m:ResponseCode>
                        <m:DescriptiveLinkKey>0</m:DescriptiveLinkKey>
                        <m:Items/>
                    </m:GetItemResponseMessage>
                </m:ResponseMessages>
            </m:GetItemResponse>
        </s:Body>
    </s:Envelope>

请指教

GetItem元素中没有遍历属性可以查看参考文档https://msdn.microsoft.com/en-us/library/aa563775(v=exchg.150).aspx

遍历仅在 FindItem 和 FindFolder 操作中有效(它指定您正在搜索的文件夹范围)。 GetItem 只是获取您具有其 Id 的特定项目(Id 包含用于定位该项目的信息,因此不需要任何 folder/mailbox 上下文)。这就是说,如果您没有特定项目的权限并且您尝试使用 GetItem,则报告的错误将是商店中不存在该项目(这有点欺骗性)。

编辑 1

您需要开始对您在 Header

中发出的所有 EWS 请求进行版本控制

  <soap:Header>
      <t:RequestServerVersion Version="Exchange2010_SP2" />
    </soap:Header>

您需要输入您使用的架构版本 https://msdn.microsoft.com/en-us/library/office/dn741586(v=exchg.150).aspx(或至少输入 Exchange2007_SP1)。这将解决 EWSId 错误(您将无法使用您尝试使用的 ID,但您应该从其他请求中获得正确的 ID)。