私は複雑な .NET クライアント サーバー アーキテクチャのカスタマイズに取り組んでおり、要求/応答オブジェクトに自分のものを追加できることを除いて、送受信される要求/応答をまったく制御できません。
クライアントに送信するサーバー側のデータセットがあり、GZipStream を使用してデータセットを圧縮しています。圧縮は正常に機能しますが、クライアント エンドで応答を受信すると、無効な文字例外 - 0x1F が発生します。私はグーグルで検索しましたが、この問題に対処するための適切なリソースが見つかりませんでした.
圧縮コード:
Private Function Compress(ByVal data() As Byte) As Byte()
Try
'---the ms is used for storing the compressed data---
Dim ms As New MemoryStream()
Dim zipStream As Stream = Nothing
zipStream = New GZipStream(ms, _
CompressionMode.Compress, True)
'---or---
'zipStream = New DeflateStream(ms, _
' CompressionMode.Compress, True)
'---compressing using the info stored in data---
zipStream.Write(data, 0, data.Length)
zipStream.Close()
ms.Position = 0
'---used to store the compressed data (byte array)---
Dim compressed_data(CInt(ms.Length - 1)) As Byte
'---read the content of the memory stream into
' the byte array---
ms.Read(compressed_data, 0, CInt(ms.Length))
Return compressed_data
Catch ex As Exception
Return Nothing
End Try
End Function
リクエスト/レスポンス処理メカニズムを変更できるという事実を考慮して、この問題を解決するためのアイデアをいただければ幸いです。さらに、Web サービスを介した大規模なデータセットの転送を処理するためのより良い方法についてのアイデアもお願いします。ありがとうございました。