共用方式為


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

Comments

  • Anonymous
    October 03, 2007
    Developers like to think their code is flawless. Admins like to think the servers are perfect, when things

  • Anonymous
    October 03, 2007
    Developers like to think their code is flawless. Admins like to think the servers are perfect, when things

  • Anonymous
    October 04, 2007
    Just FYI, because of IE6 you shouldn't enable compression for your .js, aspx files etc. unless you have the ability to compress only for targeted browsers. MS has never fully patched the problem with only half a page being rendered for some users. Try searching for:(IE6 compression Page Hangs) to see what I mean. I've found about 1 in 50 users with all latest patches and updates installed will still have this problem. On the other hand IE7 does not have this problem. IE6 is expecially hit hard by this if you are using AJAX.