Compression with Web Service data portal?

Compression with Web Service data portal?

Old forum URL: forums.lhotka.net/forums/t/10817.aspx


rsbaker0 posted on Thursday, October 27, 2011

I've done some searching to see how this is done, and have the impression it might be just a matter of including the correct incantation in the web.config on the web service side.

However, I'm a bit fuzzy on specifically what changes are required and, moreover, how does the client decompress the data on receipt?  Is there some standard infrastructure in Windows that will decompress soap messages based on the header content?

RockfordLhotka replied on Thursday, October 27, 2011

This is the old asmx portal, not WCF?

That portal does manual serialization of the data to get a byte array from the BinaryFormatter. That byte array is passed over the web service.

I would think that to do compression you'd need to create a custom version of the proxy and portal/host classes, and compress/decompress that byte array before it is passed over the wire by web services.

That's not hard - just copy the existing classes out of Csla into your project and compress/decompress the byte array with a compression library.

In the Silverlight data portal you do the same thing, but we explicitly created virtual methods so you can do this in a subclass. I suppose I'd have done the same with the asmx channel, but when WCF came along I pretty much viewed all the previous channels as legacy.

rsbaker0 replied on Friday, October 28, 2011

Thanks, Rocky. Somehow I had the impression there was a way to get IIS to handle this (e.g. web pages get httpcompression for "free" if the server supports it), so I was trying to see if there was a way to leverage this in the asmx portal.  This is not the case if I'm understanding correctly. I've done some minor modifications to asmx portal on the server side already so I can see how it might not be difficult at all to add compression.

Do you remember which version of CSLA first had the virtual methods for allowing this to be done in a subclass? (I've been backporting newer CSLA features as needed to CSLA 3.5 as needed as we aren't using Silverlight or WPF at this point and there were breaking changes introduced in the versions that introduced support for these.)

RockfordLhotka replied on Friday, October 28, 2011

IIS does offer some compression features, and this has been discussed on the forum in the past. I think there are some limits though, especially on post-back data, where the HTTP spec doesn't explicitly define a compression model (iirc).

I think the compression support for the Silverlight data portal was added in 3.7 or 3.8. You can look at the history of WcfPortal (for example) here:

http://www.lhotka.net/cslacvs/viewvc.cgi/core/trunk/Source/Csla/Server/Hosts/Silverlight/WcfPortal.cs?view=log

 

Copyright (c) Marimer LLC