Share via


WebService and IIS Compression

On the system we are building we do use Web Services with WSE3.0 for some Win / Web messaging. Just got a problem that while we are enabling IIS compression on the web server and added .asmx and other file extension to the compression section of MetaBase.xml under system32\inetserv directory, most of the file (.aspx, .html, .css, .axd, .js, etc) were compressed without problems. but the asmx file didn't be compressed.

In searching of the solution for this I got posts here states that when doing web service compression it's not only to have the server-side IIS compression features turned on and set the file extensions that wished to be compressed. there is also one more step needs to be done.

While tracing the web service request headers via Fiddler, we found that actually the request headers of asmx files didn't contain the "Accept-Encoding" header to tell IIS that the client accepts compression contents, therefore IIS won't compress the content and will send the original content back.

To enable sending the "Accept-Encoding" header in web service requests, after generating the proxy class, set the webservice proxy's "EnableDecompression"  property to "true" so that while doing the request, the web service proxy class will generate the header to tell IIS that it accepts compression.

The WSE 3.0 doc on WebServicesClientProtocol class properties states that EnableDecompression is inherited from HttpWebClientProtocol class, under the .NET 2.0 "EnableDecompression" property docs of this class stated that the default of the value is "true", but actually it's not like that while testing.

(although on the same property doc if you change to .NET framework 3.0 doc it did change the default value to be "false"!!)

Next time when you want to enable http compression on your web service request, not only set IIS server to compress dynamic files, but also remember to set proxy class to output "Accept-Encoding" header by setting the "EnableDecompression" property to "true"!

FYI

Technorati tags: microsoft, web service, wse, iis, http, compression