Asynch Web Service calls in IIS7 with Dynamic Compression


P

Paul Duncan

I need to perform an asynchronous web service call to an ASP.NET service
running on IIS 7 using Dynamic Compression, and it is failing.

I'm using the basic 'Hello World' web service, and the default proxy I
created using wsdl. I've also overridden WebResponse so that I can
decompress the GZIPPED response. Stepping through, I see that this code is
working fine and my response is getting decompressed. However, when I call
proxy.EndHelloWorld(), it throws an 'XmlException: Unexpected end of file ...
position 312'. In Fiddler, I can see that the file's content-length is 311,
but is obviously longer when decompressed.

If I call the method synchronously, it works, if I turn off Dynamic
Compression in IIS7, it works, or if I use IIS 6 it works. In IIS6, I notice
the response does not have a content-length, but rather a transfer-encoding
of 'chunked'. So, when calling IIS 7, I set a breakpoint in Fiddler and
changed the response to chunked, and it worked fine. Perhaps the answer is
to set something in IIS7 so that my responses are chunked, but it seems
strange that this doesn't just work out of the box.

Thanks for any help you can give on this,
Paul
 
Ad

Advertisements

S

Steven Cheng

Hi Paul,

From your description, you have an asmx web service (hosted in IIS) which
will be called with async mode at client-side. However, you found that when
invoking asynchronously the client-side will get some exception when try
finishing the async call, correct?

As you've tested, the service works correctly when being called
synchronously and when called asynchronously it works well under IIS 6(with
compression) but failed under IIS7(without change the http header value
manually). Thus, it does sounds like the IIS 7 dynamic compression has
issued some http headers that cause the asmx client unable to correctly
deserialize or parsing the message. So far the available compression
settings of IIS 7 is documented in the technet:

#Configuring HTTP Compression in IIS 7
http://technet.microsoft.com/en-us/library/cc771003(WS.10).aspx

for the chunked encoding, since IIS with dynamic compression cannot
calculate the entire size (without buffering the entire message), it will
not include content-length. Have you double checked the IIS 7 to see
whether the behavior comes from dynamic compression. You can try turn off
static compression and only enable dynamic compression on a specific MIME
type for test.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

--------------------
 
P

Paul Duncan

Hi Steven - thanks for your reply.

I've tried as you said and turned off all compression except for dynamic
compression on the text/* mime type. My applicationHost.config file has this
element:

<httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary
Compressed Files">
<scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" />
<dynamicTypes>
<add mimeType="text/*" enabled="true" />
<add mimeType="message/*" enabled="false" />
<add mimeType="application/x-javascript" enabled="false" />
<add mimeType="*/*" enabled="false" />
</dynamicTypes>
<staticTypes>
<add mimeType="text/*" enabled="true" />
<add mimeType="message/*" enabled="true" />
<add mimeType="application/javascript" enabled="true" />
<add mimeType="*/*" enabled="false" />
</staticTypes>
</httpCompression>

and this one:

<urlCompression doStaticCompression="false" />

Even still, my Web Service calls are coming back with Content-Length, and as
you say, the EndHelloWorld call is throwing the same exception. Is there
something I need to do to force IIS 7 to use chunked encoding?

In constructing my test app for this issue, I created a clean Windows Server
2008 instance with a new IIS7, so this issue was reproduced with mostly
out-of-the-box settings.

Thanks,
Paul
 
P

Paul Duncan

(Second reply - the first one didn't seem to make it to the forum...)

Thanks for you answer, Steve.

As you suggested, I tried turning off all compression, and then only turned
on Dynamic Compression for text/*. However I set it, I get back a
Content-Length, and as you say, an exception is thrown in EndHelloWorld. If
I turn Dynamic Compression off, it works fine.

I created a new, clean instance of Windows Server 2008/IIS 7 before trying
this and have verified that it is not working out-of-the-box. Is there
something I need to do to cause the responses to be returned as chunked
encoding?

Thanks,
Paul
 
P

Paul Duncan

Hi Steven (or others)

I'm just wondering if you are able to give me any more help on this issue,
or if I should use one of my MSDN support tickets for this.

Thanks,
Paul
 
S

Steven Cheng

Hi Paul,

Sorry for the late resposne.
As for the dynamic compression with WCF sync webservice behavior, I've also
discussed it with some IIS engineers. Seems there isn't any existing known
issue on the dynamic compression, it is likely the problem is also related
to the WCF async execution's message exchanging behavior together with the
IIS compression encoding. If this is an urgent issue and you can create a
simple and clear repro app, I agree that you can consider open a
prefessional support incident to CSS for further troubleshooting on the
underlying cause.

http://msdn.microsoft.com/en-us/subscriptions/aa948874.aspx


Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

--------------------
From: =?Utf-8?B?UGF1bCBEdW5jYW4=?= <[email protected]>
References: <078BF7F3-2F8A-4999-ADCA-[email protected]>
 
Ad

Advertisements

D

DL620

Hi Steve,

Not to hijack the thread here, but I also have similar issues. I am
implementing IIS 7.5 on 2008 R2 hosting a .net 2.0 web app making ajax/async
calls to web parts and infragistics web grids. I have enabled dynamic
compression. Regular .aspx pages load and compress fine, while pages with
webparts/chunked transfer encoded pages do not compress (they display
properly in the browser with no errors). These are 200-400kb frequently hit
pages from around the world compressed without issues with IIS6.

I need a way for IIS7.5 GZIP compression to handle these pages without
modifications to the source code or the way it makes async calls.

Thanks,


-Dave
 
P

Paul Duncan

Hi Emo,

The real answer so far is that I don't know and I have an open ticket with
Microsoft technical support. They have reproduced the issue and are working
on a solution. I will update this thread when I have an answer. I'm told it
works in IIS 7.5.

The way I turned on Dynamic Compression on IIS 7 is to install the Dynamic
Content Compression role service. If you go to your virtual directory, you
will then see Compression listed as a feature, and you can enable/disable
dynamic compression from here. You can then fine tune things in your
applcationHost.config file as I indicated above.

Hope this helps!

Paul
 
Ad

Advertisements

P

Paul Duncan

My ticket with Microsoft bore fruit!

The answer here is a simple client-side solution. My previous WebRequest
method looked like this:

protected override WebRequest GetWebRequest(Uri uri)
{
var request = base.GetWebRequest(uri);
request.Headers.Add("Accept-Encoding", "gzip");
return request;
}

The better way is this:

protected override WebRequest GetWebRequest(Uri uri)
{
var request = (HttpWebRequest) base.GetWebRequest(uri);
request.AutomaticDecompression = DecompressionMethods.GZip;
return request;
}

I'm not entirely sure why this works: The headers on the request and
response are exactly the same, but the client seems to be able to manage the
response it gets back.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top