C# MTOM-在VS 2010中读取时遇到无效的MIME内容类型标头

C# MTOM-在VS 2010中读取时遇到无效的MIME内容类型标头,c#,.net,parsing,c#-4.0,mtom,C#,.net,Parsing,C# 4.0,Mtom,我在磁盘上有一个MTOM响应,我正在尝试加载和解析该响应。 在创建MTOM读卡器时,我不断收到错误 Invalid MIME content-type header encountered on read. 这是一个bug还是内容类型的标题真的意味着VisualStudio无法理解内容类型 MIME-Version: 1.0 Content-Type: Multipart/Related;boundary=DeltaSync91ABCB4AF5D24B8F988B77ED7A19733D?MT

我在磁盘上有一个MTOM响应,我正在尝试加载和解析该响应。 在创建MTOM读卡器时,我不断收到错误

Invalid MIME content-type header encountered on read.
这是一个bug还是内容类型的标题真的意味着VisualStudio无法理解内容类型

MIME-Version: 1.0
Content-Type: Multipart/Related;boundary=DeltaSync91ABCB4AF5D24B8F988B77ED7A19733D?MTOM;
    type="application/xop+xml";
    start="<DeltaSyncMTOMFetchResponse@mail.services.live.com>";

    --DeltaSync91ABCB4AF5D24B8F988B77ED7A19733D?MTOM
    content-transfer-encoding: binary
    content-type: application/xop+xml; charset=utf-8; type="application/xop+xml"
    content-id: <DeltaSyncMTOMFetchResponse@mail.services.live.com>

    <ItemOperations xmlns:xop="http://www.w3.org/2004/08/xop/include" xmlns:B="HMMAIL:" xmlns:D="HMSYNC:" xmlns="ItemOperations:"><Status>1</Status><Responses><Fetch><ServerId>E631966A-9439-11E1-8E7B-00215AD9A7B8</ServerId><Status>1</Status><Message><xop:Include href="cid:1.634715231374437235@example.org" /></Message></Fetch></Responses></ItemOperations>
    --DeltaSync91ABCB4AF5D24B8F988B77ED7A19733D?MTOM
    content-transfer-encoding: binary
    content-type: application/octet-stream
    content-id: <1.634715231374437235@example.org>

您的数据中存在几个问题:

  • 您需要在内容类型标题中对边界字符串进行编码,因为它包含
    字符
  • 第5行到结尾缩进-您需要删除前导空格
  • 缺少结束边界字符串
以下是对我有用的修改内容:

MIME-Version: 1.0
Content-Type: Multipart/Related;boundary="DeltaSync91ABCB4AF5D24B8F988B77ED7A19733D?MTOM"";
    type="application/xop+xml"";
    start="<DeltaSyncMTOMFetchResponse@mail.services.live.com>"";

--DeltaSync91ABCB4AF5D24B8F988B77ED7A19733D?MTOM
content-transfer-encoding: binary
content-type: application/xop+xml; charset=utf-8; type="application/xop+xml""
content-id: <DeltaSyncMTOMFetchResponse@mail.services.live.com>

<ItemOperations xmlns:xop="http://www.w3.org/2004/08/xop/include"" xmlns:B=""HMMAIL:"" xmlns:D=""HMSYNC:"" xmlns=""ItemOperations:""><Status>1</Status><Responses><Fetch><ServerId>E631966A-9439-11E1-8E7B-00215AD9A7B8</ServerId><Status>1</Status><Message><xop:Include href=""cid:1.634715231374437235@example.org"" /></Message></Fetch></Responses></ItemOperations>
--DeltaSync91ABCB4AF5D24B8F988B77ED7A19733D?MTOM
content-transfer-encoding: binary
content-type: application/octet-stream
content-id: <1.634715231374437235@example.org>
--DeltaSync91ABCB4AF5D24B8F988B77ED7A19733D?MTOM--
MIME版本:1.0
内容类型:多部分/相关;boundary=“DeltaSync91ABCB4AF5D24B8F988B77ED7A19733D?MTOM”“;
type=“application/xop+xml”;
start=“”;
--DeltaSync91ABCB4AF5D24B8F988B77ED7A19733D?MTOM
内容传输编码:二进制
内容类型:application/xop+xml;charset=utf-8;type=“application/xop+xml”
内容id:

它不应该有什么区别,但是你能把
MultiPart/Related
变成小写的
MultiPart/Related
?这就是我在工作事务中经常看到的情况。名称
内容类型
被定义为不区分大小写,但我对其值非常确定。或者,您的第一部分使用的是
传输编码:二进制
,但是
内容类型
适合于文本编码而不是二进制编码?它可能不喜欢将
binary
charset=utf-8
组合使用。
MIME-Version: 1.0
Content-Type: Multipart/Related;boundary="DeltaSync91ABCB4AF5D24B8F988B77ED7A19733D?MTOM"";
    type="application/xop+xml"";
    start="<DeltaSyncMTOMFetchResponse@mail.services.live.com>"";

--DeltaSync91ABCB4AF5D24B8F988B77ED7A19733D?MTOM
content-transfer-encoding: binary
content-type: application/xop+xml; charset=utf-8; type="application/xop+xml""
content-id: <DeltaSyncMTOMFetchResponse@mail.services.live.com>

<ItemOperations xmlns:xop="http://www.w3.org/2004/08/xop/include"" xmlns:B=""HMMAIL:"" xmlns:D=""HMSYNC:"" xmlns=""ItemOperations:""><Status>1</Status><Responses><Fetch><ServerId>E631966A-9439-11E1-8E7B-00215AD9A7B8</ServerId><Status>1</Status><Message><xop:Include href=""cid:1.634715231374437235@example.org"" /></Message></Fetch></Responses></ItemOperations>
--DeltaSync91ABCB4AF5D24B8F988B77ED7A19733D?MTOM
content-transfer-encoding: binary
content-type: application/octet-stream
content-id: <1.634715231374437235@example.org>
--DeltaSync91ABCB4AF5D24B8F988B77ED7A19733D?MTOM--