Reputation: 9245
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?
Upvotes: 1
Views: 1962
Reputation: 64
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();
Upvotes: 2