【发布时间】:2021-01-20 22:37:40
【问题描述】:
我正在使用 EWS 在 Microsoft 365 中创建日历条目。我正在直接进行 http 调用并创建自己的 XML 文件,不涉及任何库。在日历对象的主体(即注释)中,我需要包含特殊字符的 UTF-8 序列。我以为我有这个工作,但现在包含这样的编码会生成 http 错误 500,并显示数据未通过架构验证的消息。
下面是我正在创建的 XML 示例。在我指出 XYZ 的地方,假设这些是 3 个字节 xE2、x82、xAC,它们是欧元字符的编码。这验证失败。如果我删除这 3 个字节,它工作正常。请注意,XML 指定了 UTF-8 编码。我还在 http 标头中设置了“Content-Type: text/xml; charset=utf-8”。知道如何指定 EWS 应处理 UTF-8 字符吗?
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
<soap:Header>
<t:RequestServerVersion Version="Exchange2010_SP1"/>
</soap:Header>
<soap:Body>
<CreateItem SendMeetingInvitations="SendToNone" xmlns="http://schemas.microsoft.com/exchange/services/2006/messages"
xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
<SavedItemFolderId>
<t:FolderId Id="AAMkADNjNjA1MTIxLWNlNmItNDBjMS04NWE0LTQ3ZmM0YTFiMTg4MAAuAAAAAADzAjMnWlbcRo51UWjY2+udAQBtGm0AIaIyTp7trMMKSGyiAAAAzNL0AAA="/>
</SavedItemFolderId>
<Items>
<t:CalendarItem>
<t:Subject>Test Euro character</t:Subject>
<t:Body BodyType="Text">
<![CDATA[
This is a Euro character: XYZ
]]>
</t:Body>
<t:Importance>Normal</t:Importance>
<t:ReminderIsSet>false</t:ReminderIsSet>
<t:Start>2010-08-24T14:30:00Z</t:Start>
<t:End>2010-08-24T15:00:00Z</t:End>
<t:LegacyFreeBusyStatus>Busy</t:LegacyFreeBusyStatus>
<t:Location></t:Location>
</t:CalendarItem>
</Items>
</CreateItem>
</soap:Body>
</soap:Envelope>
【问题讨论】:
标签: xml soap utf-8 exchangewebservices