private void InvokeAsyncCallback(IAsyncResult result) { object parameter = null; Exception exception = null; WebClientAsyncResult asyncResult = (WebClientAsyncResult)result; if (asyncResult.Request != null) { try { object o = null; Stream responseStream = null; WebResponse response = EndSend(asyncResult, ref o, ref responseStream); InvokeAsyncState invokeState = (InvokeAsyncState)o; parameter = ReadResponse(invokeState.Method, response, responseStream); } catch (Exception e) { if (e is ThreadAbortException || e is StackOverflowException || e is OutOfMemoryException) { throw; } exception = e; if (Tracing.On) { Tracing.ExceptionCatch(TraceEventType.Error, this, "InvokeAsyncCallback", e); } } } AsyncOperation asyncOp = (AsyncOperation)result.AsyncState; UserToken token = (UserToken)asyncOp.UserSuppliedState; OperationCompleted(token.UserState, new object[] { parameter }, exception, false); }
private void InvokeAsyncCallback(IAsyncResult result) { object obj2 = null; Exception e = null; WebClientAsyncResult asyncResult = (WebClientAsyncResult)result; if (asyncResult.Request != null) { try { object internalAsyncState = null; Stream responseStream = null; WebResponse response = base.EndSend(asyncResult, ref internalAsyncState, ref responseStream); InvokeAsyncState state = (InvokeAsyncState)internalAsyncState; obj2 = this.ReadResponse(state.Method, response, responseStream); } catch (Exception exception2) { if (((exception2 is ThreadAbortException) || (exception2 is StackOverflowException)) || (exception2 is OutOfMemoryException)) { throw; } e = exception2; if (Tracing.On) { Tracing.ExceptionCatch(TraceEventType.Error, this, "InvokeAsyncCallback", exception2); } } } AsyncOperation asyncState = (AsyncOperation)result.AsyncState; UserToken userSuppliedState = (UserToken)asyncState.UserSuppliedState; base.OperationCompleted(userSuppliedState.UserState, new object[] { obj2 }, e, false); }
internal override void AsyncBufferedSerialize(WebRequest request, Stream requestStream, object internalAsyncState) { InvokeAsyncState state = (InvokeAsyncState)internalAsyncState; state.Message.SetStream(requestStream); this.Serialize(state.Message); }
/// <include file='doc\SoapClientProtocol.uex' path='docs/doc[@for="SoapHttpClientProtocol.BeginInvoke"]/*' /> /// <devdoc> /// <para> /// Starts an asynchronous invocation of a method of a SOAP web /// service. /// </para> /// </devdoc> protected IAsyncResult BeginInvoke(string methodName, object[] parameters, AsyncCallback callback, object asyncState) { InvokeAsyncState invokeState = new InvokeAsyncState(methodName, parameters); WebClientAsyncResult asyncResult = new WebClientAsyncResult(this, invokeState, null, callback, asyncState); return(BeginSend(Uri, asyncResult, true)); }
protected object[] EndInvoke(IAsyncResult asyncResult) { object internalAsyncState = null; Stream responseStream = null; object[] objArray; try { WebResponse response = base.EndSend(asyncResult, ref internalAsyncState, ref responseStream); InvokeAsyncState state = (InvokeAsyncState)internalAsyncState; objArray = this.ReadResponse(state.Message, response, responseStream, true); } catch (XmlException exception) { throw new InvalidOperationException(System.Web.Services.Res.GetString("WebResponseBadXml"), exception); } finally { if (responseStream != null) { responseStream.Close(); } } return(objArray); }
internal override void AsyncBufferedSerialize(WebRequest request, Stream requestStream, object internalAsyncState) { InvokeAsyncState invokeState = (InvokeAsyncState)internalAsyncState; SoapClientMessage message = invokeState.Message; message.SetStream(requestStream); Serialize(invokeState.Message); }
protected object EndInvoke(IAsyncResult asyncResult) { object internalAsyncState = null; Stream responseStream = null; WebResponse response = base.EndSend(asyncResult, ref internalAsyncState, ref responseStream); InvokeAsyncState state = (InvokeAsyncState)internalAsyncState; return(this.ReadResponse(state.Method, response, responseStream)); }
/// <include file='doc\HttpClientProtocol.uex' path='docs/doc[@for="HttpSimpleClientProtocol.EndInvoke"]/*' /> /// <devdoc> /// <para> /// Ends an asynchronous invocation of a method of a HTTP web service. /// </para> /// </devdoc> protected object EndInvoke(IAsyncResult asyncResult) { object o = null; Stream responseStream = null; WebResponse response = EndSend(asyncResult, ref o, ref responseStream); InvokeAsyncState invokeState = (InvokeAsyncState)o; return(ReadResponse(invokeState.Method, response, responseStream)); }
/// <include file='doc\HttpClientProtocol.uex' path='docs/doc[@for="HttpSimpleClientProtocol.InitializeAsyncRequest"]/*' /> /// <devdoc> /// <para>[To be supplied.]</para> /// </devdoc> internal override void InitializeAsyncRequest(WebRequest request, object internalAsyncState) { InvokeAsyncState invokeState = (InvokeAsyncState)internalAsyncState; if (invokeState.ParamWriter.UsesWriteRequest && invokeState.Parameters.Length == 0) { request.ContentLength = 0; } }
internal override void AsyncBufferedSerialize(WebRequest request, Stream requestStream, object internalAsyncState) { InvokeAsyncState invokeState = (InvokeAsyncState)internalAsyncState; if (invokeState.ParamWriter != null) { invokeState.ParamWriter.InitializeRequest(request, invokeState.Parameters); if (invokeState.ParamWriter.UsesWriteRequest && invokeState.Parameters.Length > 0) { invokeState.ParamWriter.WriteRequest(requestStream, invokeState.Parameters); } } }
private void InvokeAsyncCallback(IAsyncResult result) { object[] parameters = null; Exception e = null; WebClientAsyncResult asyncResult = (WebClientAsyncResult)result; if (asyncResult.Request != null) { object internalAsyncState = null; Stream responseStream = null; try { WebResponse response = base.EndSend(asyncResult, ref internalAsyncState, ref responseStream); InvokeAsyncState state = (InvokeAsyncState)internalAsyncState; parameters = this.ReadResponse(state.Message, response, responseStream, true); } catch (XmlException exception2) { if (Tracing.On) { Tracing.ExceptionCatch(TraceEventType.Warning, this, "InvokeAsyncCallback", exception2); } e = new InvalidOperationException(System.Web.Services.Res.GetString("WebResponseBadXml"), exception2); } catch (Exception exception3) { if (((exception3 is ThreadAbortException) || (exception3 is StackOverflowException)) || (exception3 is OutOfMemoryException)) { throw; } if (Tracing.On) { Tracing.ExceptionCatch(TraceEventType.Warning, this, "InvokeAsyncCallback", exception3); } e = exception3; } finally { if (responseStream != null) { responseStream.Close(); } } } AsyncOperation asyncState = (AsyncOperation)result.AsyncState; UserToken userSuppliedState = (UserToken)asyncState.UserSuppliedState; base.OperationCompleted(userSuppliedState.UserState, parameters, e, false); }
protected IAsyncResult BeginInvoke(string methodName, string requestUrl, object[] parameters, AsyncCallback callback, object asyncState) { HttpClientMethod clientMethod = this.GetClientMethod(methodName); MimeParameterWriter parameterWriter = this.GetParameterWriter(clientMethod); Uri requestUri = new Uri(requestUrl); if (parameterWriter != null) { parameterWriter.RequestEncoding = base.RequestEncoding; requestUrl = parameterWriter.GetRequestUrl(requestUri.AbsoluteUri, parameters); requestUri = new Uri(requestUrl, true); } InvokeAsyncState internalAsyncState = new InvokeAsyncState(clientMethod, parameterWriter, parameters); WebClientAsyncResult asyncResult = new WebClientAsyncResult(this, internalAsyncState, null, callback, asyncState); return base.BeginSend(requestUri, asyncResult, parameterWriter.UsesWriteRequest); }
protected void InvokeAsync(string methodName, object[] parameters, SendOrPostCallback callback, object userState) { if (userState == null) { userState = base.NullToken; } InvokeAsyncState internalAsyncState = new InvokeAsyncState(methodName, parameters); AsyncOperation userAsyncState = AsyncOperationManager.CreateOperation(new UserToken(callback, userState)); WebClientAsyncResult result = new WebClientAsyncResult(this, internalAsyncState, null, new AsyncCallback(this.InvokeAsyncCallback), userAsyncState); try { base.AsyncInvokes.Add(userState, result); } catch (Exception exception) { if (((exception is ThreadAbortException) || (exception is StackOverflowException)) || (exception is OutOfMemoryException)) { throw; } if (Tracing.On) { Tracing.ExceptionCatch(TraceEventType.Warning, this, "InvokeAsync", exception); } Exception exception2 = new ArgumentException(System.Web.Services.Res.GetString("AsyncDuplicateUserState"), exception); object[] results = new object[1]; InvokeCompletedEventArgs arg = new InvokeCompletedEventArgs(results, exception2, false, userState); userAsyncState.PostOperationCompleted(callback, arg); return; } try { base.BeginSend(base.Uri, result, true); } catch (Exception exception3) { if (((exception3 is ThreadAbortException) || (exception3 is StackOverflowException)) || (exception3 is OutOfMemoryException)) { throw; } if (Tracing.On) { Tracing.ExceptionCatch(TraceEventType.Warning, this, "InvokeAsync", exception3); } object[] objArray2 = new object[1]; base.OperationCompleted(userState, objArray2, exception3, false); } }
/// <include file='doc\HttpClientProtocol.uex' path='docs/doc[@for="HttpSimpleClientProtocol.BeginInvoke"]/*' /> /// <devdoc> /// <para> /// Starts an asynchronous invocation of a method of a HTTP web service. /// </para> /// </devdoc> protected IAsyncResult BeginInvoke(string methodName, string requestUrl, object[] parameters, AsyncCallback callback, object asyncState) { HttpClientMethod method = GetClientMethod(methodName); MimeParameterWriter paramWriter = GetParameterWriter(method); Uri requestUri = new Uri(requestUrl); if (paramWriter != null) { paramWriter.RequestEncoding = RequestEncoding; requestUrl = paramWriter.GetRequestUrl(requestUri.AbsoluteUri, parameters); requestUri = new Uri(requestUrl, true); } InvokeAsyncState invokeState = new InvokeAsyncState(method, paramWriter, parameters); return(BeginSend(requestUri, invokeState, callback, asyncState, paramWriter.UsesWriteRequest)); }
/// <include file='doc\SoapClientProtocol.uex' path='docs/doc[@for="SoapHttpClientProtocol.EndInvoke"]/*' /> /// <devdoc> /// <para> /// Ends an asynchronous invocation of a method of a remote SOAP web service. /// </para> /// </devdoc> protected object[] EndInvoke(IAsyncResult asyncResult) { object o = null; Stream responseStream = null; try { WebResponse response = EndSend(asyncResult, ref o, ref responseStream); InvokeAsyncState invokeState = (InvokeAsyncState)o; return(ReadResponse(invokeState.Message, response, responseStream, true)); } finally { if (responseStream != null) { responseStream.Close(); } } }
protected IAsyncResult BeginInvoke(string methodName, string requestUrl, object[] parameters, AsyncCallback callback, object asyncState) { HttpClientMethod clientMethod = this.GetClientMethod(methodName); MimeParameterWriter parameterWriter = this.GetParameterWriter(clientMethod); Uri requestUri = new Uri(requestUrl); if (parameterWriter != null) { parameterWriter.RequestEncoding = base.RequestEncoding; requestUrl = parameterWriter.GetRequestUrl(requestUri.AbsoluteUri, parameters); requestUri = new Uri(requestUrl, true); } InvokeAsyncState internalAsyncState = new InvokeAsyncState(clientMethod, parameterWriter, parameters); WebClientAsyncResult asyncResult = new WebClientAsyncResult(this, internalAsyncState, null, callback, asyncState); return(base.BeginSend(requestUri, asyncResult, parameterWriter.UsesWriteRequest)); }
private void InvokeAsyncCallback(IAsyncResult result) { object[] parameters = null; Exception exception = null; WebClientAsyncResult asyncResult = (WebClientAsyncResult)result; if (asyncResult.Request != null) { object o = null; Stream responseStream = null; try { WebResponse response = EndSend(asyncResult, ref o, ref responseStream); InvokeAsyncState invokeState = (InvokeAsyncState)o; parameters = ReadResponse(invokeState.Message, response, responseStream, true); } catch (XmlException e) { if (Tracing.On) { Tracing.ExceptionCatch(TraceEventType.Warning, this, "InvokeAsyncCallback", e); } exception = new InvalidOperationException(Res.GetString(Res.WebResponseBadXml), e); } catch (Exception e) { if (e is ThreadAbortException || e is StackOverflowException || e is OutOfMemoryException) { throw; } if (Tracing.On) { Tracing.ExceptionCatch(TraceEventType.Warning, this, "InvokeAsyncCallback", e); } exception = e; } finally { if (responseStream != null) { responseStream.Close(); } } } AsyncOperation asyncOp = (AsyncOperation)result.AsyncState; UserToken token = (UserToken)asyncOp.UserSuppliedState; OperationCompleted(token.UserState, parameters, exception, false); }
/// <include file='doc\SoapClientProtocol.uex' path='docs/doc[@for="SoapClientProtocol.InvokeAsync1"]/*' /> /// <devdoc> /// <para>[To be supplied.]</para> /// </devdoc> protected void InvokeAsync(string methodName, object[] parameters, SendOrPostCallback callback, object userState) { if (userState == null) { userState = NullToken; } InvokeAsyncState invokeState = new InvokeAsyncState(methodName, parameters); AsyncOperation asyncOp = AsyncOperationManager.CreateOperation(new UserToken(callback, userState)); WebClientAsyncResult asyncResult = new WebClientAsyncResult(this, invokeState, null, new AsyncCallback(InvokeAsyncCallback), asyncOp); try { AsyncInvokes.Add(userState, asyncResult); } catch (Exception e) { if (e is ThreadAbortException || e is StackOverflowException || e is OutOfMemoryException) { throw; } if (Tracing.On) { Tracing.ExceptionCatch(TraceEventType.Warning, this, "InvokeAsync", e); } Exception exception = new ArgumentException(Res.GetString(Res.AsyncDuplicateUserState), e); InvokeCompletedEventArgs eventArgs = new InvokeCompletedEventArgs(new object[] { null }, exception, false, userState); asyncOp.PostOperationCompleted(callback, eventArgs); return; } try { BeginSend(Uri, asyncResult, true); } catch (Exception e) { if (e is ThreadAbortException || e is StackOverflowException || e is OutOfMemoryException) { throw; } if (Tracing.On) { Tracing.ExceptionCatch(TraceEventType.Warning, this, "InvokeAsync", e); } OperationCompleted(userState, new object[] { null }, e, false); } }
/// <include file='doc\SoapClientProtocol.uex' path='docs/doc[@for="SoapHttpClientProtocol.EndInvoke"]/*' /> /// <devdoc> /// <para> /// Ends an asynchronous invocation of a method of a remote SOAP web service. /// </para> /// </devdoc> protected object[] EndInvoke(IAsyncResult asyncResult) { object o = null; Stream responseStream = null; try { WebResponse response = EndSend(asyncResult, ref o, ref responseStream); InvokeAsyncState invokeState = (InvokeAsyncState)o; return(ReadResponse(invokeState.Message, response, responseStream, true)); } catch (XmlException e) { throw new InvalidOperationException(Res.GetString(Res.WebResponseBadXml), e); } finally { if (responseStream != null) { responseStream.Close(); } } }
/// <include file='doc\SoapClientProtocol.uex' path='docs/doc[@for="SoapClientProtocol.InvokeAsync1"]/*' /> /// <devdoc> /// <para>[To be supplied.]</para> /// </devdoc> protected void InvokeAsync(string methodName, object[] parameters, SendOrPostCallback callback, object userState) { if (userState == null) userState = NullToken; InvokeAsyncState invokeState = new InvokeAsyncState(methodName, parameters); AsyncOperation asyncOp = AsyncOperationManager.CreateOperation(new UserToken(callback, userState)); WebClientAsyncResult asyncResult = new WebClientAsyncResult(this, invokeState, null, new AsyncCallback(InvokeAsyncCallback), asyncOp); try { AsyncInvokes.Add(userState, asyncResult); } catch (Exception e) { if (e is ThreadAbortException || e is StackOverflowException || e is OutOfMemoryException) throw; if (Tracing.On) Tracing.ExceptionCatch(TraceEventType.Warning, this, "InvokeAsync", e); Exception exception = new ArgumentException(Res.GetString(Res.AsyncDuplicateUserState), e); InvokeCompletedEventArgs eventArgs = new InvokeCompletedEventArgs(new object[] { null }, exception, false, userState); asyncOp.PostOperationCompleted(callback, eventArgs); return; } try { BeginSend(Uri, asyncResult, true); } catch (Exception e) { if (e is ThreadAbortException || e is StackOverflowException || e is OutOfMemoryException) throw; if (Tracing.On) Tracing.ExceptionCatch(TraceEventType.Warning, this, "InvokeAsync", e); OperationCompleted(userState, new object[] { null }, e, false); } }
/// <include file='doc\SoapClientProtocol.uex' path='docs/doc[@for="SoapHttpClientProtocol.BeginInvoke"]/*' /> /// <devdoc> /// <para> /// Starts an asynchronous invocation of a method of a SOAP web /// service. /// </para> /// </devdoc> protected IAsyncResult BeginInvoke(string methodName, object[] parameters, AsyncCallback callback, object asyncState) { InvokeAsyncState invokeState = new InvokeAsyncState(methodName, parameters); WebClientAsyncResult asyncResult = new WebClientAsyncResult(this, invokeState, null, callback, asyncState); return BeginSend(Uri, asyncResult, true); }
/// <include file='doc\SoapClientProtocol.uex' path='docs/doc[@for="SoapHttpClientProtocol.InitializeAsyncRequest"]/*' /> /// <devdoc> /// <para>[To be supplied.]</para> /// </devdoc> internal override void InitializeAsyncRequest(WebRequest request, object internalAsyncState) { InvokeAsyncState invokeState = (InvokeAsyncState)internalAsyncState; invokeState.Message = BeforeSerialize(request, invokeState.MethodName, invokeState.Parameters); }
/// <include file='doc\SoapClientProtocol.uex' path='docs/doc[@for="SoapHttpClientProtocol.BeginInvoke"]/*' /> /// <devdoc> /// <para> /// Starts an asynchronous invocation of a method of a SOAP web /// service. /// </para> /// </devdoc> protected IAsyncResult BeginInvoke(string methodName, object[] parameters, AsyncCallback callback, object asyncState) { InvokeAsyncState invokeState = new InvokeAsyncState(methodName, parameters); return(BeginSend(Uri, invokeState, callback, asyncState, true)); }
protected void InvokeAsync(string methodName, object[] parameters, SendOrPostCallback callback, object userState) { if (userState == null) { userState = base.NullToken; } InvokeAsyncState internalAsyncState = new InvokeAsyncState(methodName, parameters); AsyncOperation userAsyncState = AsyncOperationManager.CreateOperation(new UserToken(callback, userState)); WebClientAsyncResult result = new WebClientAsyncResult(this, internalAsyncState, null, new AsyncCallback(this.InvokeAsyncCallback), userAsyncState); try { base.AsyncInvokes.Add(userState, result); } catch (Exception exception) { if (((exception is ThreadAbortException) || (exception is StackOverflowException)) || (exception is OutOfMemoryException)) { throw; } if (Tracing.On) { Tracing.ExceptionCatch(TraceEventType.Warning, this, "InvokeAsync", exception); } Exception exception2 = new ArgumentException(System.Web.Services.Res.GetString("AsyncDuplicateUserState"), exception); object[] results = new object[1]; InvokeCompletedEventArgs arg = new InvokeCompletedEventArgs(results, exception2, false, userState); userAsyncState.PostOperationCompleted(callback, arg); return; } try { base.BeginSend(base.Uri, result, true); } catch (Exception exception3) { if (((exception3 is ThreadAbortException) || (exception3 is StackOverflowException)) || (exception3 is OutOfMemoryException)) { throw; } if (Tracing.On) { Tracing.ExceptionCatch(TraceEventType.Warning, this, "InvokeAsync", exception3); } object[] objArray2 = new object[1]; base.OperationCompleted(userState, objArray2, exception3, false); } }