[Mono-bugs] [Bug 51281][Nor] Changed - SoapHttpClientProtocol - InvalidCastException when using custom WebResponse (works on MS.NET 1.1)

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Sat, 22 Nov 2003 02:03:39 -0500 (EST)


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by rsbarro@metaverse.cc.

http://bugzilla.ximian.com/show_bug.cgi?id=51281

--- shadow/51281	2003-11-22 01:22:44.000000000 -0500
+++ shadow/51281.tmp.15058	2003-11-22 02:03:39.000000000 -0500
@@ -234,6 +234,38 @@
 that the
 System.Web.Services.Protocols.SoapHttpClientProtocol:ReceiveResponse
 method is choking on the fact that it's getting a class that inherits
 from System.Net.WebResponse, rather than a genuine
 System.Net.WebResponse class.  Again, this code works fine on the MS
 .NET 1.1 Framework.
+
+------- Additional Comments From rsbarro@metaverse.cc  2003-11-22 02:03 -------
+I now see why this error is occurring.  See the code below:
+
+object [] ReceiveResponse
+   (WebResponse response, 
+    SoapClientMessage message, 
+    SoapExtension[] extensions)
+{
+  HttpWebResponse http_response = (HttpWebResponse) response;
+  HttpStatusCode code = http_response.StatusCode;
+  SoapMethodStubInfo msi = message.MethodStubInfo;
+
+  if (!(code == HttpStatusCode.Accepted || code == HttpStatusCode.OK
+|| code == HttpStatusCode.InternalServerError))
+ throw new Exception ("Return code was: " + http_response.StatusCode);
+
+The first line of the method is where the invalid cast occurs.  My
+question is, why cast to an HttpWebResponse?  It seems like the only
+information that is used from the HttpWebResponse cast is the status
+code (lines 263 and 284).  The use seems trivial however, and the
+MS.NET Framework must not attempt the same cast (otherwise my test
+case wouldn't work =] ).
+
+I would propose that the HttpWebResponse cast be removed and the
+success of ResponseReceived can be determined by whether or not the
+code executes all of the way through.  Try catch the code after line
+284 (bool isSuccessful = ...) and return an exception if it fails.  Is
+there a reason why this solution won't work...?
+
+Thanks,
+Rich