* SoapHttpClientProtocol.cs: Replaced AsyncInfo by a new
authorLluis Sanchez <lluis@novell.com>
Sun, 12 Oct 2003 23:09:33 +0000 (23:09 -0000)
committerLluis Sanchez <lluis@novell.com>
Sun, 12 Oct 2003 23:09:33 +0000 (23:09 -0000)
  SoapWebClientAsyncResult class derived from WebClientAsyncResult.
* WebClientAsyncResult.cs: Removed unneeded members.

svn path=/trunk/mcs/; revision=18939

mcs/class/System.Web.Services/System.Web.Services.Protocols/ChangeLog
mcs/class/System.Web.Services/System.Web.Services.Protocols/SoapHttpClientProtocol.cs
mcs/class/System.Web.Services/System.Web.Services.Protocols/WebClientAsyncResult.cs

index f3b4efb469e1501aaafa7bc3e374f60fe7b0d6ff..c0f87f350700fbddf72b65438713f22756af55b9 100644 (file)
@@ -1,3 +1,9 @@
+2003-10-12  Lluis Sanchez Gual <lluis@ximian.com>
+
+       * SoapHttpClientProtocol.cs: Replaced AsyncInfo by a new 
+         SoapWebClientAsyncResult class derived from WebClientAsyncResult.
+       * WebClientAsyncResult.cs: Removed unneeded members.
+
 2003-10-10  Gonzalo Paniagua Javier <gonzalo@ximian.com>
 
        * SoapDocumentationHandler.cs: don't close the response stream here
index b88faa2f635fb6056277cb2129fbd29ec505f754..de76ce7aae96238d2d5ad3623822ac5e1373538a 100644 (file)
@@ -29,70 +29,17 @@ namespace System.Web.Services.Protocols {
        public class SoapHttpClientProtocol : HttpWebClientProtocol {\r
                SoapTypeStubInfo type_info;\r
 \r
-               #region AsyncInfo class\r
+               #region SoapWebClientAsyncResult class\r
 \r
-               internal class AsyncInfo: IAsyncResult\r
+               internal class SoapWebClientAsyncResult: WebClientAsyncResult\r
                {\r
-                       bool _completedSynchronously;\r
-                       bool _done;\r
-                       ManualResetEvent _waitHandle;\r
-\r
-                       public object AsyncState \r
+                       public SoapWebClientAsyncResult (WebRequest request, AsyncCallback callback, object asyncState)\r
+                       : base (request, callback, asyncState)\r
                        {\r
-                               get { return InternalAsyncState; }\r
                        }\r
-\r
-                       public WaitHandle AsyncWaitHandle \r
-                       {\r
-                               get\r
-                               {\r
-                                       lock (this) {\r
-                                               if (_waitHandle != null) return _waitHandle;\r
-                                               _waitHandle = new ManualResetEvent (_done);\r
-                                               return _waitHandle;\r
-                                       }\r
-                               }\r
-                       }\r
-\r
-                       public bool CompletedSynchronously \r
-                       {\r
-                               get { return _completedSynchronously; }\r
-                       }\r
-\r
-                       public bool IsCompleted \r
-                       {\r
-                               get { lock (this) { return _done; } }\r
-                       }\r
-\r
-                       internal void SetCompleted (object[] result, Exception exception, bool async)\r
-                       {\r
-                               lock (this)\r
-                               {\r
-                                       Exception = exception;\r
-                                       Result = result;\r
-                                       _done = true;\r
-                                       _completedSynchronously = async;\r
-                                       if (_waitHandle != null) _waitHandle.Set ();\r
-                                       Monitor.PulseAll (this);\r
-                               }\r
-                               if (Callback != null) Callback (this);\r
-                       }\r
-\r
-                       internal void WaitForComplete ()\r
-                       {\r
-                               lock (this)\r
-                               {\r
-                                       Monitor.Wait (this);\r
-                               }\r
-                       }\r
-\r
-                       internal object InternalAsyncState;\r
-                       internal AsyncCallback Callback;\r
-                       internal SoapClientMessage Message;\r
-                       internal SoapExtension[] Extensions;\r
-                       internal WebRequest Request;\r
-                       internal object[] Result;\r
-                       internal Exception Exception;\r
+               \r
+                       public SoapClientMessage Message;\r
+                       public SoapExtension[] Extensions;\r
                }\r
                #endregion\r
 \r
@@ -109,23 +56,26 @@ namespace System.Web.Services.Protocols {
 \r
                protected IAsyncResult BeginInvoke (string methodName, object[] parameters, AsyncCallback callback, object asyncState)\r
                {\r
-                       AsyncInfo ainfo = new AsyncInfo ();\r
-\r
                        SoapMethodStubInfo msi = (SoapMethodStubInfo) type_info.GetMethod (methodName);\r
-                       ainfo.Message = new SoapClientMessage (this, msi, Url, parameters);\r
-                       ainfo.Message.CollectHeaders (this, ainfo.Message.MethodStubInfo.Headers, SoapHeaderDirection.In);\r
-                       ainfo.Extensions = SoapExtension.CreateExtensionChain (type_info.SoapExtensions[0], msi.SoapExtensions, type_info.SoapExtensions[1]);\r
-                       ainfo.InternalAsyncState = asyncState;\r
-                       ainfo.Callback = callback;\r
 \r
+                       SoapWebClientAsyncResult ainfo = null;\r
                        try\r
                        {\r
-                               ainfo.Request = GetRequestForMessage (uri, ainfo.Message);\r
+                               SoapClientMessage message = new SoapClientMessage (this, msi, Url, parameters);\r
+                               message.CollectHeaders (this, message.MethodStubInfo.Headers, SoapHeaderDirection.In);\r
+                               \r
+                               WebRequest request = GetRequestForMessage (uri, message);\r
+                               \r
+                               ainfo = new SoapWebClientAsyncResult (request, callback, asyncState);\r
+                               ainfo.Message = message;\r
+                               ainfo.Extensions = SoapExtension.CreateExtensionChain (type_info.SoapExtensions[0], msi.SoapExtensions, type_info.SoapExtensions[1]);\r
+\r
                                ainfo.Request.BeginGetRequestStream (new AsyncCallback (AsyncGetRequestStreamDone), ainfo);\r
                        }\r
                        catch (Exception ex)\r
                        {\r
-                               ainfo.SetCompleted (null, ex, false);\r
+                               if (ainfo != null)\r
+                                       ainfo.SetCompleted (null, ex, false);\r
                        }\r
 \r
                        return ainfo;\r
@@ -133,28 +83,29 @@ namespace System.Web.Services.Protocols {
 \r
                void AsyncGetRequestStreamDone (IAsyncResult ar)\r
                {\r
-                       AsyncInfo ainfo = (AsyncInfo) ar.AsyncState;\r
+                       SoapWebClientAsyncResult ainfo = (SoapWebClientAsyncResult) ar.AsyncState;\r
                        try\r
                        {\r
                                SendRequest (ainfo.Request.EndGetRequestStream (ar), ainfo.Message, ainfo.Extensions);\r
-\r
                                ainfo.Request.BeginGetResponse (new AsyncCallback (AsyncGetResponseDone), ainfo);\r
                        }\r
                        catch (Exception ex)\r
                        {\r
+                               Console.WriteLine ("E1:" + ex);\r
                                ainfo.SetCompleted (null, ex, true);\r
                        }\r
                }\r
 \r
                void AsyncGetResponseDone (IAsyncResult ar)\r
                {\r
-                       AsyncInfo ainfo = (AsyncInfo) ar.AsyncState;\r
+                       SoapWebClientAsyncResult ainfo = (SoapWebClientAsyncResult) ar.AsyncState;\r
                        WebResponse response = null;\r
 \r
                        try {\r
                                response = GetWebResponse (ainfo.Request, ar);\r
                        }\r
                        catch (WebException ex) {\r
+                               Console.WriteLine ("E2:" + ex);\r
                                response = ex.Response;\r
                                HttpWebResponse http_response = response as HttpWebResponse;\r
                                if (http_response == null || http_response.StatusCode != HttpStatusCode.InternalServerError) {\r
@@ -178,14 +129,14 @@ namespace System.Web.Services.Protocols {
 \r
                protected object[] EndInvoke (IAsyncResult asyncResult)\r
                {\r
-                       if (!(asyncResult is AsyncInfo)) throw new ArgumentException ("asyncResult is not the return value from BeginInvoke");\r
+                       if (!(asyncResult is SoapWebClientAsyncResult)) throw new ArgumentException ("asyncResult is not the return value from BeginInvoke");\r
 \r
-                       AsyncInfo ainfo = (AsyncInfo) asyncResult;\r
+                       SoapWebClientAsyncResult ainfo = (SoapWebClientAsyncResult) asyncResult;\r
                        lock (ainfo)\r
                        {\r
                                if (!ainfo.IsCompleted) ainfo.WaitForComplete ();\r
                                if (ainfo.Exception != null) throw ainfo.Exception;\r
-                               else return ainfo.Result;\r
+                               else return (object[]) ainfo.Result;\r
                        }\r
                }\r
 \r
index 5a1f3e116e113c279487fc1e7c11f2b30cc47c2f..6b4848835a7cdb8338ea62391752b15ec40a1f09 100644 (file)
@@ -23,9 +23,6 @@ namespace System.Web.Services.Protocols {
                bool _done;\r
                ManualResetEvent _waitHandle;\r
                \r
-               internal SoapClientMessage Message;\r
-               internal SoapExtension[] Extensions;\r
-\r
                internal object Result;\r
                internal Exception Exception;\r
                internal WebRequest Request;\r