web service ( + WSE 2.0 ) hangs after adding an output filter

D

DaberElay

Hi,
I have a server that returns a dataset of over 10,000 records. i added a output filter to the web.config file and i zip the body,create an empty body and add the zip as an attachment ( using #ZipLib freeware project ) in the processMessage method, it all runs fine and in a responsive manner.
on the client side i add an input filter to the pipeline that do exactly the oposite : i unzip the attachment & replace the body with the unzip version.

i have 2 problems : 1. between the server's filter end of call and the call to the client filter, i'm unresponsive for as much as +30 seconds ( changing each run ).
2. the client filter is being called twice, i can overcome this but it proves that there is a problem.

I attached the code in question,

please advise,
much appriciated.



server side code :
XmlElement soapHeader = envelope.CreateHeader();
XmlDocument document = soapHeader.OwnerDocument;
XmlElement customHeader = document.CreateElement( "ZipFilter" );
customHeader.SetAttribute("bZipped","1");
soapHeader.AppendChild(customHeader);

MemoryStream original = new MemoryStream( System.Text.Encoding.UTF8.GetBytes(envelope.Body.InnerXml ) );

MemoryStream Zipped = new MemoryStream();
ICSharpCode.SharpZipLib.BZip2.BZip2.Compress( original,Zipped,1024);

MemoryStream res = new MemoryStream( Zipped.GetBuffer() );
Microsoft.Web.Services2.Attachments.Attachment attch = new Microsoft.Web.Services2.Attachments.Attachment( "APPLICATION/OCTET-STREAM",res );
envelope.Context.Attachments.Add( attch );
XmlElement newBody = envelope.CreateBody();
newBody.RemoveAll();
envelope.SetBodyObject( newBody );

client side code :
XmlNodeList elemList = envelope.Header.GetElementsByTagName("ZipFilter");
if ( elemList[0].Attributes["bZipped"].Value.Equals("0") )
return;
envelope.Header.RemoveChild( elemList[0] );
Stream original = envelope.Context.Attachments[0].Stream;
MemoryStream UnZipped = new MemoryStream();
ICSharpCode.SharpZipLib.BZip2.BZip2.Decompress( original,UnZipped );
XmlElement body = envelope.CreateBody();
body.InnerXml = System.Text.Encoding.UTF8.GetString( UnZipped.GetBuffer() );
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top