I'm working on a complex .NET client server architecture customization and I absolutely have no control over request/reply sent or received except that I can add my stuff to the request/reply objects.
I've a dataset on server side to be sent to client andI'm using GZipStream to compress the dataset. The compression works fine, but when the reply is received on client end, I get invalid character exception - 0x1F. I googled and could not find appropriate resource to address开发者_如何学运维 this issue.
Compression code:
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
Any idea to fix this issue considering the fact that I can alter the request/response handling mechanism is really appreciated. In addition, I also request any ideas on better ways handling large dataset transfers over webservice. Thank you.
精彩评论