使用EWS SOAP在电子邮件上设置ErrorSchemaValidation错误标志

时间:2016-01-17 04:18:14

标签: exchangewebservices

我一直在尝试使用带有SOAP的Exchange Web服务(UpdateItem操作)在电子邮件上设置各种标志类型时出现ErrorSchemaValidation错误。以下是此类错误的示例:

<?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 'PropertyTag' attribute is invalid - The value '802A' is invalid according to its datatype 'http://schemas.microsoft.com/exchange/services/2006/types:PropertyTagType' - The value '802A' is not valid according to any of the memberTypes of the union.</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>1</t:LineNumber>
          <t:LinePosition>1340</t:LinePosition>
          <t:Violation>The 'PropertyTag' attribute is invalid - The value '802A' is invalid according to its datatype 'http://schemas.microsoft.com/exchange/services/2006/types:PropertyTagType' - The value '802A' is not valid according to any of the memberTypes of the union.</t:Violation>
        </t:MessageXml>
      </detail>
    </s:Fault>
  </s:Body>
</s:Envelope>

这是我的要求,按照规范添加一个简单的彩色标志:https://msdn.microsoft.com/en-us/library/ee204317(v=exchg.80).aspx

<?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:xsd="http://www.w3.org/2001/XMLSchema"               xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"               xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
  <soap:Header>
    <RequestServerVersion Version="Exchange2013" xmlns="http://schemas.microsoft.com/exchange/services/2006/types"/>
  </soap:Header>
  <soap:Body>
    <m:UpdateItem MessageDisposition="SaveOnly" ConflictResolution="AlwaysOverwrite">
      <m:ItemChanges>
        <t:ItemChange>
          <t:ItemId Id="AAMkAGUzNmEzYTBmLTI1NDItNGE0My1iZDk5LWFkMDgxODI3YWNlOQBGAAAAAACK2VEhi72QSaw+u0XV7xUHBwAA/rMO2DXYS7rgpZoTIdkqABsXDgCjAAAuH/1UA8tzTYD5jbYriaIUAAIZ7oMeAAA=" />
          <t:Updates>
            <t:SetItemField>
              <t:ExtendedFieldURI PropertyTag="1095" PropertyType="Integer" />
              <t:Message>
                <t:ExtendedProperty>
                  <t:ExtendedFieldURI PropertyTag="1095" PropertyType="Integer" />
                  <t:Value>6</t:Value>
                </t:ExtendedProperty>
              </t:Message>
            </t:SetItemField>
            <t:SetItemField>
              <t:ExtendedFieldURI PropertyTag="802A" PropertyType="String"/>
              <t:Message>
                <t:ExtendedProperty>
                  <t:ExtendedFieldURI PropertyTag="802A" PropertyType="String"/>
                  <t:Value>Follow up</t:Value>
                </t:ExtendedProperty>
              </t:Message>
            </t:SetItemField>
            <t:SetItemField>
              <t:ExtendedFieldURI PropertyTag="83C0" PropertyType="Integer" />
              <t:Message>
                <t:ExtendedProperty>
                  <t:ExtendedFieldURI PropertyTag="83C0" PropertyType="Integer" />
                  <t:Value>3</t:Value>
                </t:ExtendedProperty>
              </t:Message>
            </t:SetItemField>
            <t:SetItemField>
              <t:ExtendedFieldURI PropertyTag="83CA" PropertyType="SystemTime" />
              <t:Message>
                <t:ExtendedProperty>
                  <t:ExtendedFieldURI PropertyTag="83CA" PropertyType="SystemTime" />
                  <t:Value>2016-01-17T03:56:50.972Z</t:Value>
                </t:ExtendedProperty>
              </t:Message>
            </t:SetItemField>
            <t:SetItemField>
              <t:ExtendedFieldURI PropertyTag="1090" PropertyType="Integer" />
              <t:Message>
                <t:ExtendedProperty>
                  <t:ExtendedFieldURI PropertyTag="1090" PropertyType="Integer" />
                  <t:Value>2</t:Value>
                </t:ExtendedProperty>
              </t:Message>
            </t:SetItemField>
            <t:SetItemField>
              <t:ExtendedFieldURI PropertyTag="0C17" PropertyType="Boolean" />
              <t:Message>
                <t:ExtendedProperty>
                  <t:ExtendedFieldURI PropertyTag="0C17" PropertyType="Boolean" />
                  <t:Value>True</t:Value>
                </t:ExtendedProperty>
              </t:Message>
            </t:SetItemField>
            <t:SetItemField>
              <t:ExtendedFieldURI PropertyTag="0063" PropertyType="Boolean" />
              <t:Message>
                <t:ExtendedProperty>
                  <t:ExtendedFieldURI PropertyTag="0063" PropertyType="Boolean" />
                  <t:Value>True</t:Value>
                </t:ExtendedProperty>
              </t:Message>
            </t:SetItemField>
          </t:Updates>
        </t:ItemChange>
      </m:ItemChanges>
    </m:UpdateItem>
  </soap:Body>
</soap:Envelope>

我开始设置时间标记(根据规范:https://msdn.microsoft.com/en-us/library/ee201784(v=exchg.80).aspx)但我得到了相同的模式验证错误。我尝试从请求中删除各种属性,但这并不重要 - 它会在另一个字段上出错。所以我试图用一个颜色标记进行简化,因为时间标记非常复杂,我只想验证这是否可以先完成。

我做错了什么?

1 个答案:

答案 0 :(得分:2)

您尝试在0x8000范围内设置的属性是命名属性,并且您尝试将它们用作标记属性,这些属性不起作用(您的十六进制标记值前面也缺少0x)。您需要定义和使用这些属性,如

&#13;
&#13;
<t:Updates>
  <t:SetItemField>
    <t:ExtendedFieldURI DistinguishedPropertySetId="Common" PropertyId="34096" PropertyType="String" />
    <t:Message>
      <t:ExtendedProperty>
        <t:ExtendedFieldURI DistinguishedPropertySetId="Common" PropertyId="34096" PropertyType="String" />
        <t:Value>Follow up</t:Value>
      </t:ExtendedProperty>
    </t:Message>
  </t:SetItemField>
  <t:SetItemField>
    <t:ExtendedFieldURI PropertyTag="4245" PropertyType="Integer" />

    <t:Message>
      <t:ExtendedProperty>
        <t:ExtendedFieldURI PropertyTag="4245" PropertyType="Integer" />
        <t:Value>6</t:Value>
      </t:ExtendedProperty>
    </t:Message>
  </t:SetItemField>
  <t:SetItemField>
    <t:ExtendedFieldURI PropertyTag="4240" PropertyType="Integer" />

    <t:Message>
      <t:ExtendedProperty>
        <t:ExtendedFieldURI PropertyTag="4240" PropertyType="Integer" />
        <t:Value>2</t:Value>
      </t:ExtendedProperty>
    </t:Message>
  </t:SetItemField>
  <t:SetItemField>
    <t:ExtendedFieldURI PropertyTag="3627" PropertyType="Integer" />

    <t:Message>
      <t:ExtendedProperty>
        <t:ExtendedFieldURI PropertyTag="3627" PropertyType="Integer" />
        <t:Value>1</t:Value>
      </t:ExtendedProperty>
    </t:Message>
  </t:SetItemField>
  <t:SetItemField>
    <t:ExtendedFieldURI DistinguishedPropertySetId="Common" PropertyId="34208" PropertyType="SystemTime" />
    <t:Message>
      <t:ExtendedProperty>
        <t:ExtendedFieldURI DistinguishedPropertySetId="Common" PropertyId="34208" PropertyType="SystemTime" />
        <t:Value>2016-01-19T12:24:28.320+11:00</t:Value>
      </t:ExtendedProperty>
    </t:Message>
  </t:SetItemField>
  <t:SetItemField>
    <t:ExtendedFieldURI DistinguishedPropertySetId="Task" PropertyId="33028" PropertyType="SystemTime" />
    <t:Message>
      <t:ExtendedProperty>
        <t:ExtendedFieldURI DistinguishedPropertySetId="Task" PropertyId="33028" PropertyType="SystemTime" />
        <t:Value>2016-01-18T12:24:28.320+11:00</t:Value>
      </t:ExtendedProperty>
    </t:Message>
  </t:SetItemField>
  <t:SetItemField>
    <t:ExtendedFieldURI DistinguishedPropertySetId="Task" PropertyId="33029" PropertyType="SystemTime" />
    <t:Message>
      <t:ExtendedProperty>
        <t:ExtendedFieldURI DistinguishedPropertySetId="Task" PropertyId="33029" PropertyType="SystemTime" />
        <t:Value>2016-01-19T12:24:28.320+11:00</t:Value>
      </t:ExtendedProperty>
    </t:Message>
  </t:SetItemField>
  <t:SetItemField>
    <t:ExtendedFieldURI DistinguishedPropertySetId="Common" PropertyId="34070" PropertyType="SystemTime" />
    <t:Message>
      <t:ExtendedProperty>
        <t:ExtendedFieldURI DistinguishedPropertySetId="Common" PropertyId="34070" PropertyType="SystemTime" />
        <t:Value>2016-01-17T13:00:00.000Z</t:Value>
      </t:ExtendedProperty>
    </t:Message>
  </t:SetItemField>
  <t:SetItemField>
    <t:ExtendedFieldURI DistinguishedPropertySetId="Common" PropertyId="34071" PropertyType="SystemTime" />
    <t:Message>
      <t:ExtendedProperty>
        <t:ExtendedFieldURI DistinguishedPropertySetId="Common" PropertyId="34071" PropertyType="SystemTime" />
        <t:Value>2016-01-17T13:00:00.000Z</t:Value>
      </t:ExtendedProperty>
    </t:Message>
  </t:SetItemField>
</t:Updates>
&#13;
&#13;
&#13;

同样在Exchange 2013中,Flags有一个强类型属性,因此您可以设置标记的大部分时间扩展属性,例如

&#13;
&#13;
<t:Updates>
  <t:SetItemField>
    <t:FieldURI FieldURI="item:Flag" />
    <t:Message>
      <t:Flag>
        <t:FlagStatus>Flagged</t:FlagStatus>
        <t:StartDate>2016-01-18T01:37:21.626Z</t:StartDate>
        <t:DueDate>2016-01-19T01:37:21.626Z</t:DueDate>
      </t:Flag>
    </t:Message>
  </t:SetItemField>
</t:Updates>
&#13;
&#13;
&#13;

干杯 格伦