5
votes

I have a RESTful WCF web service written in C# using .NET 4.0, and I'd like the responses to be compressed using GZip or deflate. (I might need to support compression for requests too, but that is not yet a requirement). It will be deployed as a windows service, i.e. self-hosted WCF service, as IIS hosting is not an option.

My searches have so far come up short. Most hits are either for turning on compression in IIS or writing a custom message encoder for a SOAP based service, neither or which fit my scenario.

If you have any pointers for how to do this, it would be greatly appreciated!

1

1 Answers

1
votes

You really need to go for the custom encoder route (sample with code at http://msdn.microsoft.com/en-us/library/ms751458.aspx) if you want to do GZip compression in a self-hosted scenario (on 4.5 it looks like there is support for compression on the binary encoding, per the announcement at the MSDN WCF Forums, but it doesn't exist out-of-the-box for 4.0). Why doesn't the custom encoder work for your scenario?