Esempio n. 1
0
        /// <summary>
        /// Sends a message-based request and returns the correlated message-based response
        /// </summary>
        /// <param name="message">The request System.ServiceModel.Channels.Message to be transmitted</param>
        /// <returns>The System.ServiceModel.Channels.Message received in response to the request</returns>
        public Message Request(Message message)
        {
            WCFLogger.Write(TraceEventType.Start, "Beginning to intercept request");
            base.ThrowIfDisposedOrNotOpen();
            Message interceptedResponseMessage = null;

            try
            {
                Message interceptedRequestMessage = InterceptRequest(message);
                Message innerMessage = InnerChannel.Request(interceptedRequestMessage);
                interceptedResponseMessage = InterceptResponse(innerMessage);
                WCFLogger.Write(TraceEventType.Stop, "Finished intercepting request");
            }
            catch (CryptographicException exception)
            {
                // Exception, if the service e.g. does not have acces to the private key in the certificate
                // So logging this special error
                this.logger.Fatal("The service migth not have permission right to the private key in the certificate", exception);

                // handling the error as normal
                HandleException(message);
                WCFLogger.Write(TraceEventType.Error, "Exception occurred while intercepting: " + exception);
                WCFLogger.Write(TraceEventType.Stop, "Finished intercepting request");
                throw exception;
            }
            catch (Exception exception)
            {
                HandleException(message);
                WCFLogger.Write(TraceEventType.Error, "Exception occurred while intercepting: " + exception);
                WCFLogger.Write(TraceEventType.Stop, "Finished intercepting request");
                throw exception;
            }

            return(interceptedResponseMessage);
        }
Esempio n. 2
0
        protected override void OnSend(Message message, TimeSpan timeout)
        {
            PrepareForSend(message);
            Message responseMessage = InnerChannel.Request(message, timeout);

            if (responseMessage != null)
            {
                this.EnqueueAndDispatch(responseMessage, null, false);
            }
            this.poller.EnsurePolling(this);
        }
        protected override void OnClose(TimeSpan timeout)
        {
            TimeoutHelper timeoutHelper = new TimeoutHelper(timeout);

            if (exchangeTerminateMessage)
            {
                Message terminateSessionResponse = InnerChannel.Request(
                    CreateTerminateSessionRequest(),
                    timeoutHelper.RemainingTime());
                ValidateTerminateSessionResponse(terminateSessionResponse);
            }
            base.Close(timeoutHelper.RemainingTime());
        }
Esempio n. 4
0
        public Message Request(Message message, TimeSpan timeout)
        {
            TimeoutHelper timeoutHelper = new TimeoutHelper(timeout);

            WriteTransactionDataToMessage(message, MessageDirection.Input);
            Message reply = InnerChannel.Request(message, timeoutHelper.RemainingTime());

            if (reply != null)
            {
                this.ReadIssuedTokens(reply, MessageDirection.Output);
            }
            return(reply);
        }
Esempio n. 5
0
        /// <summary>
        ///  Sends a message-based request and returns the correlated message-based response
        ///  within a specified interval of time
        /// </summary>
        /// <param name="message">The request System.ServiceModel.Channels.Message to be transmitted</param>
        /// <param name="timeout">The System.TimeSpan that specifies the interval of time within which a response
        /// must be received</param>
        /// <returns>The System.ServiceModel.Channels.Message received in response to the request</returns>
        public Message Request(Message message, TimeSpan timeout)
        {
            WCFLogger.Write(TraceEventType.Start, "Beginning to intercept request");
            base.ThrowIfDisposedOrNotOpen();

            Message interceptedResponseMessage = null;

            try
            {
                Message interceptedRequestMessage = InterceptRequest(message);
                WCFLogger.Write(TraceEventType.Verbose, "Interceptor Requesting");
                Message innerMessage = InnerChannel.Request(interceptedRequestMessage, timeout);
                interceptedResponseMessage = InterceptResponse(innerMessage);
                WCFLogger.Write(TraceEventType.Stop, "Finished intercepting request");
            }
            catch (Exception ex)
            {
                HandleException(message);
                WCFLogger.Write(TraceEventType.Error, "Exception occurred while intercepting: " + ex);
                throw ex;
            }

            return(interceptedResponseMessage);
        }