Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Services > Exception in web service client from EndInvoke with compressed WebResponse

Reply
Thread Tools

Exception in web service client from EndInvoke with compressed WebResponse

 
 
Mike Henderson
Guest
Posts: n/a
 
      10-14-2004
I'm having trouble decompressing a stream asynchronously in my web
service client application. I'm using a proxy class derived from the
SoapHttpClientProtocol class. I have a CompressedHttpWebResponse
wrapper class to decompress the gzip responses that I get from the
server. It's derived from WebResponse and overrides the
GetResponseStream() method to return the the decompressed stream.
Everything works perfectly when I call my web methods synchronously,
but when I call them asynchronously I get the following exception when
calling the MyWebService.EndMyMethod() portion of the async web
method:

System.ArgumentNullException: Value cannot be null.
Parameter name: stream
at System.IO.StreamReader..ctor(Stream stream, Encoding encoding,
Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize)
at System.Web.Services.Protocols.SoapHttpClientProtoc ol.ReadResponse(SoapClientMessage
message, WebResponse response, Stream responseStream, Boolean
asyncCall)
at System.Web.Services.Protocols.SoapHttpClientProtoc ol.EndInvoke(IAsyncResult
asyncResult)
at MyWebService.EndMyMethod(IAsyncResult asyncResult)


The code that I added to the SoapHttpClientProtocol derived class is
as follows:


protected override System.Net.WebRequest GetWebRequest(Uri uri)
{
HttpWebRequest webRequest = (HttpWebRequest)base.GetWebRequest
(uri);
webRequest.Headers.Add("Accept-Encoding","gzip");
webRequest.KeepAlive = false;

return webRequest;
}

protected override WebResponse GetWebResponse(WebRequest request,
IAsyncResult result)
{
WebResponse response = base.GetWebResponse(request,result);
CompressedHttpWebResponse compressedResponse = new
CompressedHttpWebResponse(response as HttpWebResponse);
return compressedResponse;
}


protected override WebResponse GetWebResponse(WebRequest request)
{
WebResponse response = base.GetWebResponse (request);
CompressedHttpWebResponse compressedResponse = new
CompressedHttpWebResponse(response as HttpWebResponse);
return compressedResponse;
}

Even without compression, I get the exception when I return my wrapper
class and not an HttpWebResponse from GetWebResponse, so the EndInvoke
must only be able to handle HttpWebResponse.

I looked at the WebClientAsyncResult that the callback method
receives. It has an internal stream property called 'Buffer'. When I
make the async GetWebResponse call return the result of
base.GetWebResponse() this property has a valid value, but it is null
when I return my CompressedHttpWebResponse. Could this be what is
causing the error? I can't figure out anyway to set it...
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Forwarding WebResponse File To Web Browser Jeff G. ASP .Net 3 05-20-2010 01:17 PM
WEBREQUEST AND WEBRESPONSE PROBLEM Savas Ates ASP .Net 4 01-24-2006 07:22 PM
Delegate Endinvoke Kill thread chintan jajal via .NET 247 ASP .Net 1 06-06-2005 06:31 PM
How to get HTML from a relative URL? WebRequest, WebResponse won't work in my case John ASP .Net 1 03-05-2005 11:06 AM
WebClient and WebResponse eats up memory ScottO ASP .Net 2 11-03-2003 05:27 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57