V
Vincent xu via .NET 247
public override Stream ChainStream(Stream stream)
{
oldStream = stream;
newStream = new MemoryStream();
return newStream;
}
When I use this method, it occurs a mistake.
At the BeforeDeserialize stage, oldStream accepts the right stream. It works well.
But at the AfterSerialize stage, the stream passed into the method as following made me sad:
stream {System.Web.Services.Protocols.SoapExtensionStream}
System.MarshalByRefObject {System.Web.Services.Protocols.SoapExtensionStream}System.MarshalByRefObject
Length <error: an exception of type: {System.InvalidOperationException} occurred> long
Null {System.IO.Stream.NullStream} System.IO.Stream
Position <error: an exception of type: {System.InvalidOperationException} occurred> long
So when I continue to call the following method, I can't write anything into oldStream.
private void Compress(SoapMessage message)
{
if(message is SoapServerMessage)
{
newStream.Position = 0;
StreamReader reader = new StreamReader(newStream);
StreamWriter writer = new StreamWriter(oldStream);
string UnCompressedString = reader.ReadToEnd();
string CompressedString = MyZipLib.Zip.Deflate(UnCompressedString);
writer.WriteLine(CompressedString);
writer.Flush();
}
}
{
oldStream = stream;
newStream = new MemoryStream();
return newStream;
}
When I use this method, it occurs a mistake.
At the BeforeDeserialize stage, oldStream accepts the right stream. It works well.
But at the AfterSerialize stage, the stream passed into the method as following made me sad:
stream {System.Web.Services.Protocols.SoapExtensionStream}
System.MarshalByRefObject {System.Web.Services.Protocols.SoapExtensionStream}System.MarshalByRefObject
Length <error: an exception of type: {System.InvalidOperationException} occurred> long
Null {System.IO.Stream.NullStream} System.IO.Stream
Position <error: an exception of type: {System.InvalidOperationException} occurred> long
So when I continue to call the following method, I can't write anything into oldStream.
private void Compress(SoapMessage message)
{
if(message is SoapServerMessage)
{
newStream.Position = 0;
StreamReader reader = new StreamReader(newStream);
StreamWriter writer = new StreamWriter(oldStream);
string UnCompressedString = reader.ReadToEnd();
string CompressedString = MyZipLib.Zip.Deflate(UnCompressedString);
writer.WriteLine(CompressedString);
writer.Flush();
}
}