在EWS FindItem请求中使用限制时的架构验证错误

时间:2017-04-12 09:51:02

标签: soap wsdl exchange-server exchangewebservices

我试图使用ItemClass = IPM.Note

在收件箱中查找项目
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  xmlns:tns="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:wsi="http://ws-i.org/schemas/conformanceClaim/">
    <soap:Header>
        <t:RequestServerVersion Version="Exchange2010_SP2"></t:RequestServerVersion>
    </soap:Header>

    <soap:Body>
        <FindItem Traversal="Shallow" xmlns="http://schemas.microsoft.com/exchange/services/2006/messages">
            <ItemShape>
                <t:BaseShape xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">IdOnly</t:BaseShape>
                <t:AdditionalProperties xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
                    <t:FieldURI FieldURI="item:ItemClass"></t:FieldURI>
                </t:AdditionalProperties>
            </ItemShape>

            <IndexedPageItemView MaxEntriesReturned="50" Offset="0" BasePoint="Beginning"></IndexedPageItemView>

            <Restriction>
                <IsEqualTo>
                    <FieldURI FieldURI="item:ItemClass"></FieldURI>
                    <FieldURIOrConstant>
                        <Constant Value="IPM.Note"></Constant>
                    </FieldURIOrConstant>
                </IsEqualTo>
            </Restriction>

            <ParentFolderIds>
                <t:DistinguishedFolderId Id="inbox" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types"></t:DistinguishedFolderId>
            </ParentFolderIds>

        </FindItem>
    </soap:Body>
</soap:Envelope>

导致此SchemaValidationError

a:ErrorSchemaValidation: The request failed schema validation: The element 'Restriction' in namespace 'http://schemas.microsoft.com/exchange/services/2006/messages' has invalid child element 'IsEqualTo' in namespace 'http://schemas.microsoft.com/exchange/services/2006/messages'. List of possible elements expected: 'SearchExpression' in namespace 'http://schemas.microsoft.com/exchange/services/2006/types'. [undefined] Error: a:ErrorSchemaValidation: The request failed schema validation: The element 'Restriction' in namespace 'http://schemas.microsoft.com/exchange/services/2006/messages' has invalid child element 'IsEqualTo' in namespace 'http://schemas.microsoft.com/exchange/services/2006/messages'. List of possible elements expected: 'SearchExpression' in namespace 'http://schemas.microsoft.com/exchange/services/2006/types'.

至于我的理解,SearchExpression is an abstract type that can be replaced with IsEqualTo以及其他类型。

我在这里缺少什么?

1 个答案:

答案 0 :(得分:0)

其中一些元素位于“类型”命名空间中,因此需要t:前缀

        <Restriction>
            <t:IsEqualTo>
                <t:FieldURI FieldURI="item:ItemClass"></t:FieldURI>
                <t:FieldURIOrConstant>
                    <t:Constant Value="IPM.Note"></t:Constant>
                </t:FieldURIOrConstant>
            </t:IsEqualTo>
        </Restriction>