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

时间:2016-06-08 10:41:50

标签: soap exchangewebservices exchange-server-2010

我有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:

我删除了遍历属性而不是出错:

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

请告知。

1 个答案:

答案 0 :(得分:1)

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

遍历仅在FindItem和FindFolder操作中有效(它指定您要搜索的文件夹的范围)。 GetItem只是获取您拥有Id的特定项目(该Id包含用于查找项目的信息,因此不需要任何文件夹/邮箱上下文)。也就是说,如果您没有特定Item的权限,并且您尝试使用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)。