Esempio n. 1
0
        /// <summary>
        /// begins an asynchronous operation to reply to the request associated with the current
        /// context within a specified interval of time
        /// </summary>
        /// <param name="message">The incoming System.ServiceModel.Channels.Message that contains the request</param>
        /// <param name="timeout">The System.Timespan that specifies the interval of time to wait for the reply
        /// to an available request</param>
        /// <param name="callback">The System.AsyncCallback delegate that receives the notification of the asynchronous
        /// reply operation completion</param>
        /// <param name="state">An object, specified by the application, that contains state information
        /// associated with the asynchronous reply operation</param>
        /// <returns>The System.IAsyncResult that references the asynchronous reply operation</returns>
        public override IAsyncResult BeginReply(Message message, TimeSpan timeout, AsyncCallback callback, object state)
        {
            WCFLogger.Write(TraceEventType.Verbose, "InterceptorRequestContext begins reply");
            Message interceptedMessage = InterceptResponse(message);

            return(_innerContext.BeginReply(interceptedMessage, timeout, callback, state));
        }
Esempio n. 2
0
 public override IAsyncResult BeginReply(
     Message message,
     TimeSpan timeout,
     AsyncCallback callback,
     object state
     )
 {
     ConfigureResponseMessage(message);
     return(_innerContext.BeginReply(message, timeout, callback, state));
 }
                public override IAsyncResult BeginReply(Message message, TimeSpan timeout, AsyncCallback callback, object state)
                {
                    Message m = message;

                    this.OnSend(ref m);
                    return(_innerContext.BeginReply(m, timeout, callback, state));
                }
Esempio n. 4
0
        private void ProvideFaultAndReplyFailure(RequestContext request, Exception exception, ref ErrorHandlerFaultInfo faultInfo, out bool replied, out bool replySentAsync)
        {
            replied        = false;
            replySentAsync = false;
            bool requestMessageIsFault = false;

            try
            {
                requestMessageIsFault = request.RequestMessage.IsFault;
            }
#pragma warning suppress 56500 // covered by FxCOP
            catch (Exception e)
            {
                if (Fx.IsFatal(e))
                {
                    throw;
                }
                // do not propagate non-fatal exceptions
            }

            bool enableFaults = false;
            if (_listener != null)
            {
                enableFaults = _listener.ChannelDispatcher.EnableFaults;
            }
            else if (_channel != null && _channel.IsClient)
            {
                enableFaults = _channel.ClientRuntime.EnableFaults;
            }

            if ((!requestMessageIsFault) && enableFaults)
            {
                this.ProvideFault(exception, ref faultInfo);
                if (faultInfo.Fault != null)
                {
                    Message reply = faultInfo.Fault;
                    try
                    {
                        try
                        {
                            if (this.PrepareReply(request, reply))
                            {
                                if (_sendAsynchronously)
                                {
                                    var state = new ContinuationState {
                                        ChannelHandler = this, Channel = _channel, Exception = exception, FaultInfo = faultInfo, Request = request, Reply = reply
                                    };
                                    var result = request.BeginReply(reply, ChannelHandler.s_onAsyncReplyComplete, state);
                                    if (result.CompletedSynchronously)
                                    {
                                        ChannelHandler.AsyncReplyComplete(result, state);
                                        replied = true;
                                    }
                                    else
                                    {
                                        replySentAsync = true;
                                    }
                                }
                                else
                                {
                                    request.Reply(reply);
                                    replied = true;
                                }
                            }
                        }
                        finally
                        {
                            if (!replySentAsync)
                            {
                                reply.Close();
                            }
                        }
                    }
#pragma warning suppress 56500 // covered by FxCOP
                    catch (Exception e)
                    {
                        if (Fx.IsFatal(e))
                        {
                            throw;
                        }
                        this.HandleError(e);
                    }
                }
            }
        }
Esempio n. 5
0
 public override IAsyncResult BeginReply(Message message, AsyncCallback callback, object state)
 {
     return(src.BeginReply(message, callback, state));
 }
 public override IAsyncResult BeginReply(Message message, AsyncCallback callback, object state)
 {
     AddSessionData(message);
     return(innerRequestContext.BeginReply(
                message, callback, state));
 }