【问题标题】:Parameter name 'key' cannot be null for EWS SOAP UpdateItem callEWS SOAP UpdateItem 调用的参数名称“键”不能为空
【发布时间】:2020-03-16 14:24:53
【问题描述】:

我在尝试更新日历约会时收到Parameter name: key 的内部服务器错误。
它“不能为空”。这意味着什么?没有参数'key'。 &#xD 是报告的值吗?
当在 SO 上浏览 Parameter name 'key' cannot be null 时,我认为这可能是 Exchange Server 本身的编程错误。

select @@version 给出:
Microsoft SQL Server 2016 (SP1-CU2) (KB4013106) - 13.0.4422.0 (X64)
2017 年 3 月 6 日 14:18:16
版权所有 (c) Microsoft Corporation
Windows Server 2012 R2 Standard 6.3(Build 9600:)(Hypervisor)上的标准版(64 位)

这是回复:

<?xml version="1.0" encoding="utf-8"?>
  <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
  <s:Header>
    <h:ServerVersionInfo MajorVersion="15" MinorVersion="20" MajorBuildNumber="2814" MinorBuildNumber="22" Version="V2018_01_08" xmlns:h="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
  </s:Header>
  <s:Body>
    <m:UpdateItemResponse xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
      <m:ResponseMessages>
        <m:UpdateItemResponseMessage ResponseClass="Error">
          <m:MessageText>An internal server error occurred. The operation failed., Value cannot be null.&#xD;
          Parameter name: key</m:MessageText>
          <m:ResponseCode>ErrorInternalServerError</m:ResponseCode>
          <m:DescriptiveLinkKey>0</m:DescriptiveLinkKey>
          <m:Items/>
        </m:UpdateItemResponseMessage>
      </m:ResponseMessages>
    </m:UpdateItemResponse>
  </s:Body>
</s:Envelope>

对此请求:

<soapenv:Envelope
  xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
  xmlns:typ="http://schemas.microsoft.com/exchange/services/2006/types"
  xmlns:mes="http://schemas.microsoft.com/exchange/services/2006/messages">
<soapenv:Header>
  <typ:RequestServerVersion Version="Exchange2010"/>
  <typ:MailboxCulture>en-US</typ:MailboxCulture>
  <typ:TimeZoneContext>
     <typ:TimeZoneDefinition Id="W. Europe Standard Time"/>
  </typ:TimeZoneContext>
</soapenv:Header>
<soapenv:Body>
<mes:UpdateItem ConflictResolution="AlwaysOverwrite" SendMeetingInvitationsOrCancellations="SendToNone">
   <mes:ItemChanges>
      <typ:ItemChange>
         <typ:ItemId Id="AQMkAGMz[snip]AAAA==" ChangeKey="DwAA[snip]JuniP+" />
         <typ:Updates>
            <typ:SetItemField>
               <typ:FieldURI FieldURI="item:Subject"/>
               <typ:CalendarItem>
                 <typ:Subject>Gewijzigde afspraak? Ik denk het wel</typ:Subject>
               </typ:CalendarItem>
            </typ:SetItemField>
            <typ:SetItemField>
               <typ:FieldURI FieldURI="item:Sensitivity"/>
               <typ:CalendarItem>
                 <typ:Sensitivity>Normal</typ:Sensitivity>
               </typ:CalendarItem>
            </typ:SetItemField>
            <typ:SetItemField>
               <typ:FieldURI FieldURI="item:Categories"/>
               <typ:CalendarItem>
                  <typ:Categories>
                     <typ:String>TimeTell</typ:String>
                  </typ:Categories>
               </typ:CalendarItem>
            </typ:SetItemField>
            <typ:SetItemField>
               <typ:FieldURI FieldURI="item:Body"/>
               <typ:CalendarItem>
                 <typ:Body BodyType="Text">Aangemaakt door Wendy</typ:Body>
               </typ:CalendarItem>
            </typ:SetItemField>
            <typ:SetItemField>
               <typ:FieldURI FieldURI="calendar:Location"/>
               <typ:CalendarItem>
                 <typ:Location></typ:Location>
               </typ:CalendarItem>
            </typ:SetItemField>
            <typ:SetItemField>
               <typ:FieldURI FieldURI="calendar:IsAllDayEvent"/>
               <typ:CalendarItem>
                 <typ:IsAllDayEvent>false</typ:IsAllDayEvent>
               </typ:CalendarItem>
            </typ:SetItemField>
            <typ:SetItemField>
               <typ:FieldURI FieldURI="calendar:Start"/>
               <typ:CalendarItem>
                 <typ:Start>2020-03-31T16:56:27.929+02:00</typ:Start>
               </typ:CalendarItem>
            </typ:SetItemField>
            <typ:SetItemField>
               <typ:FieldURI FieldURI="calendar:End"/>
               <typ:CalendarItem>
                 <typ:End>2020-03-31T17:56:27.929+02:00</typ:End>
               </typ:CalendarItem>
            </typ:SetItemField>
            <typ:SetItemField>
               <typ:FieldURI FieldURI="calendar:LegacyFreeBusyStatus"/>
               <typ:CalendarItem>
                 <typ:LegacyFreeBusyStatus>Busy</typ:LegacyFreeBusyStatus>
               </typ:CalendarItem>
            </typ:SetItemField>
            <typ:SetItemField>
               <typ:FieldURI FieldURI="calendar:StartTimeZone"/>
               <typ:CalendarItem>
                  <typ:StartTimeZone TimeZoneName="W. Europe Standard Time"/>
               </typ:CalendarItem>
            </typ:SetItemField>
            <typ:SetItemField>
               <typ:FieldURI FieldURI="calendar:EndTimeZone"/>
               <typ:CalendarItem>
                  <typ:EndTimeZone TimeZoneName="W. Europe Standard Time"/>
               </typ:CalendarItem>
            </typ:SetItemField>
         </typ:Updates>
      </typ:ItemChange>
   </mes:ItemChanges>
</mes:UpdateItem>
</soapenv:Body>
</soapenv:Envelope>

【问题讨论】:

    标签: soap exchange-server exchangewebservices


    【解决方案1】:

    哇,这真是难以预料。

    我已经用 nSoftware 的 IPWorks 中的 TipwHTTP 替换了 THTTPReqResp 组件。这使用了所有普通的 String 类型。

    但是发送到 EWS 的数据需要是 UTF-8

    毕竟我们说ContentType := 'text/xml; charset=utf-8'*
    转换后我的代码仍然显示:

    lHTTP.PostData := FSoapRequest;   // A string type
    

    但应该是:

    lHTTP.PostDataB := BytesOf(UTF8Encode(FSoapRequest));   // UTF8Encode returns a UTF-8 encoded RawByteString with a code page of CP_UTF8 (65001) assigned to it.
    

    我通过仔细查看失败的 SOAP 调用发现了这一点。它们包含诸如单词“左单引号”(U-2018,人们只是将 Word 文本复制/粘贴到电子邮件中)之类的东西,甚至是像 é 和 ü 这样的简单变音符号,它们会导致这些错误。

    * 是的,不带引号的 'utf-8',因为这正是 Exchange Webservices 想要的

    注意事项:

    • 这是非常具体的,所以我想只是删除问题,但是 EWS 提供的信息不超过“内部服务器错误”的情况也可能发生在其他人身上。很高兴将此作为调查指针。
    • 有限的错误信息让我发问How to get more detailed error info in EWS SOAP response?

    【讨论】:

      猜你喜欢
      • 2014-05-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-01-16
      • 2016-05-14
      • 2015-11-05
      • 2019-05-26
      • 2014-10-29
      相关资源
      最近更新 更多