0

C# ベースの ActiveSync クライアントを使用していますが、Sendmail コマンドをサーバーに送信しようとすると問題が発生します。次の形式の MIME データでテストしています。

    var testMsg = @"From: a@b.com
To: a@b.com
Cc:
Bcc:
Subject: From NSync
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: base64
VGhpcyBpcyB0aGUgYm9keSB0ZXh0Lg==";

    var data = UTF8Encoding.UTF8.GetBytes(testMsg);

サーバーがデータを取得すると、Exchange クライアント ログに次の例外が記録されます。

Command_WorkerThread_Exception : 
--- Exception start ---
Exception type: Microsoft.Exchange.AirSync.Wbxml.WbxmlException
Exception message: Invalid WBXML code/codepage from client
Exception level: 0
Exception stack trace:    at Microsoft.Exchange.AirSync.Wbxml.WbxmlReader.ReadXmlDocument()
   at Microsoft.Exchange.AirSync.AirSyncRequest.get_XmlDocument()
   at Microsoft.Exchange.AirSync.Command.get_XmlRequest()
   at Microsoft.Exchange.AirSync.Command.WorkerThread()
Inner exception follows...
Exception type: System.IndexOutOfRangeException
Exception message: Index was outside the bounds of the array.
Exception level: 1
Exception stack trace:    at Microsoft.Exchange.AirSync.Wbxml.WbxmlSchema30.GetName(Int32 tag)
   at Microsoft.Exchange.AirSync.Wbxml.WbxmlReader.FillXmlElement(XmlElement elem, Int32 depth, Boolean elemIsSecureData, Boolean elemIsBlobData)
   at Microsoft.Exchange.AirSync.Wbxml.WbxmlReader.FillXmlElement(XmlElement elem, Int32 depth, Boolean elemIsSecureData, Boolean elemIsBlobData)
   at Microsoft.Exchange.AirSync.Wbxml.WbxmlReader.ReadXmlDocument()
--- Exception end ---
4

1 に答える 1

0

私の問題は、送信されたメッセージとは何の関係もないことがわかりました。この問題は、WBXML にシリアル化する方法に関係していました。

Opaque データを書き込む場合、MIME コンテンツの場合、最初にデータ長を配置し、その後にバイト配列を配置する必要があります。データの長さを書き込むコードがオフになっていたため、問題が発生しました。

于 2013-12-20T21:21:45.933 に答える