views:

1467

answers:

2

Hi,

I currently use a custom gzip encoder for my WCF service. I want to replace it with the built-in IIS 7 compression if that is possible. I can't find info online on how to that.

Is there any way to enable IIS 7 compression for WCF services? Do you know if this will be supported out-of-the-box with .Net 4?

Edit June 15th: I'm still looking for a way to replace our custom gzip encoder with a mainstream approach so if you know how to do that with .Net 4 and IIS 7, please answer this question.

Thanks


Sidebar : My attempt at doing this manually

Since I can't find how to do it by simply turning a few knobs I decided to try and enable it manually.

So far I have:

  • Installed and enabled the IIS 7 Dynamic Compression Module
  • Changed the section of the applicationHost.config file to enable compression for mimeType="application/soap+xml" and mimeType="application/xop+xml".

I used an HTTP sniffer to sniff traffic sent from my app (Windows Forms). I see that requests do not have the Accept-Encoding:gzip,deflate http header.

So I

  • Added it manually to all outgoing calls using the OperationContextScope class and its OutgoingMessageProperties. (I will post the details later if I find the solution).

With the http sniffer, I can see that the client header now has the correct header:

POST /### path to my service ####/MyService.svc HTTP/1.1
MIME-Version: 1.0
Content-Type: multipart/related; type="application/xop+xml";
    start="<http://tempuri.org/0&gt;";
    boundary="uuid:####### some uuid #############";
    start-info="application/soap+xml"
Accept-Encoding: gzip,deflate
Host: ####### my server name #############
Content-Length: 1753
Expect: 100-continue

But the server response is still not compressed.

Why is the server response not compressed? Have I used the correct mime types? Once I get the server to return a compressed answer, will the client automatically decompress it or will have to write code on the client side to decompress?


Thanks for your help

+1  A: 

Perhaps it depends on the specific WCF service setup you are using, but for the applications I have used it in (all were mixed access for both .NET applications and Silverlight pages), the generated WCF client class contained an EnableDecompression property that can be set to true. After that my Winforms apps send the correct headers and the webservice communication is correctly compressed.

David Hay
Thanks for your answer. My client app is a basic WinForms application so I should be able to use EnableDecompression. Your answer implies that you have successfully enabled compression on the server. Was it on IIS 7? How did you configure it? Any idea why I can't get the server to return compressed responses?
Sly