【问题标题】:The 'Traversal' attribute is not declared. In GetItem EWS request未声明“遍历”属性。在 GetItem EWS 请求中
【发布时间】:2016-06-08 10:41:50
【问题描述】:

我有 EWS 肥皂请求:

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

我删除了 traversal 属性,但出现错误:

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

然后我删除了最后一个附加属性

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

请指教。

【问题讨论】:

    标签: soap exchangewebservices exchange-server-2010


    【解决方案1】:

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

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

    编辑 1

    您需要开始对您在标头中发出的所有 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)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-01-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多