Friday, December 03, 2010

How to use IIS Compression with Web Services

Using IIS compression with web services is a simple way to provide better performance for your services.  This article will detail implementing this solution in IIS6 and IIS7.

First, you need to ensure that the web service proxy in your application has the following property set to true;

Dim myService as new localhost.service1
myService.EnableDecompression = True

This will ensure that your application takes advantage of the compression.


Second, you need to configure IIS compression on your server.  To do this ensure that you have the following installed;image

Then turn compression on in the IIS management console;


Then create a bat file in C:\inetpub\AdminScripts and place the following lines of code into the bat file;

IISreset.exe /stop
cscript.exe adsutil.vbs set w3svc/filters/compression/parameters/HcDoDynamicCompression true
cscript.exe adsutil.vbs set w3svc/filters/compression/parameters/HcDoStaticCompression true
cscript.exe adsutil.vbs set W3Svc/Filters/Compression/GZIP/HcFileExtensions "htm" "html" "txt" "ppt" "xls" "xml" "pdf" "xslt" "doc" "xsl" "htc" "js" "css"
cscript.exe adsutil.vbs set W3Svc/Filters/Compression/DEFLATE/HcFileExtensions "htm" "html" "txt" "ppt" "xls" "xml" "pdf" "xslt" "doc" "xsl" "htc" "js" "css"
cscript.exe adsutil.vbs set W3Svc/Filters/Compression/GZIP/HcScriptFileExtensions "asp" "dll" "exe" "aspx" "asmx" "ashx"
cscript.exe adsutil.vbs set W3Svc/Filters/Compression/DEFLATE/HcScriptFileExtensions "asp" "dll" "exe" "aspx" "asmx"
cscript.exe adsutil.vbs set W3Svc/Filters/Compression/DEFLATE/HcScriptFileExtensions "asp" "dll" "exe" "aspx" "asmx"
cscript.exe adsutil.vbs set W3Svc/Filters/Compression/DEFLATE/HcDynamicCompressionLevel "9"
IISreset.exe /restart

This will enable compression on your web service.

The following tool is a easy free application that allows you to compare the difference in your application communication between compressed and uncompressed communications of xml data.


1 comment:

Anonymous said...

Thanks! Great post!