0

将此请求发送到 EWS 时(注意主题中的“ä”):

POST /EWS/Exchange.asmx HTTP/1.1
Content-Type: text/xml; chartype=UTF-8
Connection: keep-alive
Host: ...
Authorization: Basic ...
Content-Length: ...

<?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:t="http://schemas.microsoft.com/exchange/services/2006/types">
  <soap:Body>
    <CreateItem xmlns="http://schemas.microsoft.com/exchange/services/2006/messages"
                xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" 
                SendMeetingInvitations="SendToAllAndSaveCopy" >
      <SavedItemFolderId>
        <t:DistinguishedFolderId Id="calendar"/>
      </SavedItemFolderId>
      <Items>
        <t:CalendarItem xmlns="http://schemas.microsoft.com/exchange/services/2006/types">
          <t:Subject>ITGeschäft</t:Subject>
          <t:Body BodyType="Text">...</t:Body>
          <t:ReminderIsSet>false</t:ReminderIsSet>
          <t:ReminderMinutesBeforeStart>10</t:ReminderMinutesBeforeStart>
          <t:Start>2013-08-06T12:31:57</t:Start>
          <t:End>2013-08-06T15:31:57</t:End>
          <t:IsAllDayEvent>false</t:IsAllDayEvent>
          <t:LegacyFreeBusyStatus>Busy</t:LegacyFreeBusyStatus>
          <t:Location></t:Location>
        </t:CalendarItem>
      </Items>
    </CreateItem>
  </soap:Body>
</soap:Envelope>

我收到这样的错误响应:

 - soap11:Envelope xmlns:soap11="http://schemas.xmlsoap.org/soap/envelope/"
 -- soap11:Header
 --- t:ServerVersionInfo MajorVersion="8" MinorVersion="3" MajorBuildNumber="83" MinorBuildNumber="4" xmlns:t="http://schemas.m
icrosoft.com/exchange/services/2006/types" /
 -- soap11:Body
 --- soap11:Fault
 ---- faultcode
        = soap11:Client
 ---- faultstring
        = Fehler bei der Schema├╝berpr├╝fung der Anforderung: Unerwartetes Dateiende. Die folgenden Elemente wurden nicht geschlossen: soap:Envelope. Zeile 28, Position 16.
 ---- detail
 ----- e:ResponseCode xmlns:e="http://schemas.microsoft.com/exchange/services/2006/errors"
         = ErrorSchemaValidation
 ----- e:Message xmlns:e="http://schemas.microsoft.com/exchange/services/2006/errors"
         = Unerwartetes Dateiende. Die folgenden Elemente wurden nicht geschlossen: soap:Envelope. Zeile 28, Position 16.
 ----- e:Line xmlns:e="http://schemas.microsoft.com/exchange/services/2006/errors"
         = 28
 ----- e:Position xmlns:e="http://schemas.microsoft.com/exchange/services/2006/errors"
         = 16

但是当我发送

...
          <t:Subject>ITGeschaeft</t:Subject>
...

它有效,CalendarItem 已正确创建。我是如何发送非 ASCII 字符的?

顺便说一句,它的另一种工作方式是 GetItem 正确传输这些特殊字符。请求以 utf-8 正确编码。还尝试了 Iso-Latin1,得到编码错误。

4

1 回答 1

0

在 ISO-8859-1 中对请求和 xml 进行编码工作:

Content-Type: text/xml; charset=ISO-8859-1

……

<?xml version="1.0" encoding="ISO-8859-1"?>
于 2012-05-30T09:06:05.353 回答