问题
I would like to compress the data coming out of WCF on a basicHttpBinding.
I am trying to produce a new version of a system originally written as SOAP web services. In that we returned a GZipStream when we received a request.
Is there any way to do the same with WCF?
I am using VS2010, currently against .Net 3.5 but that's flexible.
Thanks
回答1:
If you plan to use IIS hosting and .NET 4.0 client you can use build in dynamic content compression in IIS. If client sends Accept-Encoding: gzip/deflate header to the service IIS will compresses the response for you. .NET 4.0 client is able to automatically decompress the response. Check Support for HTTP Decompression section.
回答2:
This page may help? It has a sample of a Compression Encoder.
http://msdn.microsoft.com/en-us/library/ms751458.aspx
来源:https://stackoverflow.com/questions/3735501/compressing-data-coming-out-of-wcf