views:

310

answers:

1

I have a .NET 3.5 web app hosted on Windows Azure that exposes several WCF endpoints (both SOAP and REST). The endpoints typically receive 100x more data than they serve (lot of data is upload, much fewer is downloaded).

Hence, I am willing to take advantage from HTTP GZip compression but not from the server viewpoint, but rather from the client viewpoint, sending compressed requests (returning compressed responses would be fine, but won't bring much gain anyway).

Here is the little C# snippet used on the client side to activate WCF:

var binding = new BasicHttpBinding();
var address = new EndpointAddress(endPoint);

_factory = new ChannelFactory<IMyApi>(binding, address);
_channel = _factory.CreateChannel(); 

Any idea how to adjust the behavior so that compressed HTTP requests can be made?

+1  A: 

If you would like to use a commercial component then try this. It provides standard-based HTTP compression for both requests and responses. I am not sure whether Azure supports decompressing compressed requests, if it doesn't then you can also use it on Azure to provide decompression. Here is your binding modified as needed:

using Noemax.WCFX.Channels;

var binding = new BasicHttpBinding();
var address = new EndpointAddress(endPoint);

ContentNegotiationBindingElement contentNegotiation = new ContentNegotiationBindingElement();
contentNegotiation.CompressionMode = SmartCompressionMode.Optimistic;

binding = contentNegotiation.PlugIn(binding);

_factory = new ChannelFactory<IMyApi>(binding, address);
_channel = _factory.CreateChannel(); 
Alexander Philippou
Thanks for the suggestion, unfortunately, the client is open-source, so I guess this won't work for me. Yet, I can try to replicate the small behavior that I need.
Joannes Vermorel
@Joannes By chance are you writing that behavior using the GZipStream class? I'd be interested in seeing the code when you are finished, as I'm embarking on a project with similar goals.
Richard B
Richard, I am sorry, but we never found the time so far to move forward on that one.
Joannes Vermorel