Имя параметра «ключ» не может быть нулевым для вызова EWS SOAP UpdateItem - PullRequest
0 голосов
/ 16 марта 2020

Я получаю внутреннюю ошибку сервера для Parameter name: key при попытке обновить встречу в календаре. Это не может быть нулем. Что это может значить? Там нет параметра «ключ». Является ли &#xD значением, о котором сообщается? При просмотре SO на Имя параметра 'ключ' не может быть нулевым Я понимаю, что это может быть программная ошибка в самом Exchange Server.

select @@version дает: Microsoft SQL Server 2016 (SP1-CU2) (KB4013106) - 13.0.4422.0 (X64) 6 марта 2017 14:18:16 Авторские права (c) Microsoft Corporation Standard Edition (64-разрядная версия) на Windows Server 2012 R2 Standard 6.3 (сборка 9600:) (гипервизор)

Это ответ:

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

1 Ответ

0 голосов
/ 25 марта 2020

Ого, это было действительно непредсказуемо.

Я заменил THTTPReqResp компоненты на TipwHTTP из IPWorks nSoftware. При этом используются все обычные типы String.

Но данные, отправляемые в EWS, должны быть в формате UTF-8

В конце концов мы говорим set 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

Примечания:

  • Это довольно специфично c, поэтому Я думал об удалении вопроса, но ситуация, когда EWS не дает больше информации, чем «Внутренняя ошибка сервера», может возникнуть и для других. Хорошо бы оставить это как указатель для расследования.
  • Ограниченная информация об ошибках заставила меня задать вопрос Как получить более подробную информацию об ошибках в ответе EWS SOAP?
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...