Asynch Web Service calls in IIS7 with Dynamic Compression

Discussion in 'ASP .Net Web Services' started by Paul Duncan, Jan 4, 2010.

  1. Paul Duncan

    Paul Duncan Guest

    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
     
    Paul Duncan, Jan 4, 2010
    #1
    1. Advertising

  2. Paul Duncan

    Steven Cheng Guest

    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

    --------------------
    >From: =?Utf-8?B?UGF1bCBEdW5jYW4=?= <>
    >Subject: Asynch Web Service calls in IIS7 with Dynamic Compression
    >Date: Mon, 4 Jan 2010 10:17:01 -0800


    >
    >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
    >
     
    Steven Cheng, Jan 5, 2010
    #2
    1. Advertising

  3. Paul Duncan

    Paul Duncan Guest

    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

    ""Steven Cheng"" wrote:

    > 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
    >
    > --------------------
    > >From: =?Utf-8?B?UGF1bCBEdW5jYW4=?= <>
    > >Subject: Asynch Web Service calls in IIS7 with Dynamic Compression
    > >Date: Mon, 4 Jan 2010 10:17:01 -0800

    >
    > >
    > >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
    > >

    >
    > .
    >
     
    Paul Duncan, Jan 5, 2010
    #3
  4. Paul Duncan

    Paul Duncan Guest

    (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

    ""Steven Cheng"" wrote:

    > 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
    >
    > --------------------
    > >From: =?Utf-8?B?UGF1bCBEdW5jYW4=?= <>
    > >Subject: Asynch Web Service calls in IIS7 with Dynamic Compression
    > >Date: Mon, 4 Jan 2010 10:17:01 -0800

    >
    > >
    > >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
    > >

    >
    > .
    >
     
    Paul Duncan, Jan 5, 2010
    #4
  5. Paul Duncan

    Paul Duncan Guest

    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
     
    Paul Duncan, Jan 27, 2010
    #5
  6. Paul Duncan

    Steven Cheng Guest

    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:
    .

    --------------------
    >From: =?Utf-8?B?UGF1bCBEdW5jYW4=?= <>
    >References: <>

    <>
    <>
    >Subject: RE: Asynch Web Service calls in IIS7 with Dynamic Compression
    >Date: Wed, 27 Jan 2010 08:53:03 -0800


    >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
    >
     
    Steven Cheng, Feb 1, 2010
    #6
  7. Paul Duncan

    DL620 Guest

    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


    ""Steven Cheng"" wrote:

    > 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:
    > .
    >
    > --------------------
    > >From: =?Utf-8?B?UGF1bCBEdW5jYW4=?= <>
    > >References: <>

    > <>
    > <>
    > >Subject: RE: Asynch Web Service calls in IIS7 with Dynamic Compression
    > >Date: Wed, 27 Jan 2010 08:53:03 -0800

    >
    > >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
    > >

    >
    > .
    >
     
    DL620, Feb 4, 2010
    #7
  8. Paul Duncan

    Paul Duncan Guest

    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
     
    Paul Duncan, Feb 8, 2010
    #8
  9. Paul Duncan

    Paul Duncan Guest

    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.
     
    Paul Duncan, Feb 10, 2010
    #9
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    2
    Views:
    1,126
  2. Isaias Formacio Serna

    Web Service that calls an external Web Service

    Isaias Formacio Serna, Jan 28, 2004, in forum: ASP .Net Security
    Replies:
    5
    Views:
    259
  3. Tony T.

    Calling an Asynch web service within a web service.

    Tony T., Apr 26, 2004, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    199
    Tony T.
    Apr 26, 2004
  4. Hans Baumann

    Asynch calls from a Web Form

    Hans Baumann, Jan 24, 2006, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    137
    Hans Baumann
    Jan 24, 2006
  5. Paul Duncan
    Replies:
    0
    Views:
    755
    Paul Duncan
    Dec 18, 2009
Loading...

Share This Page