コード例 #1
0
        public override void InterceptResponse(dk.gov.oiosi.extension.wcf.Interceptor.Channels.InterceptorMessage interceptorMessage)
        {
            // Get the message, uncopied
            Message msg = interceptorMessage.GetMessage();

            // Add the headers
            msg.Headers.Add(MessageHeader.CreateHeader(
                                _senderPartyIdentifierHeaderName.Name,
                                _senderPartyIdentifierHeaderName.Namespace,
                                _senderPartyIdentifier));

            msg.Headers.Add(MessageHeader.CreateHeader(
                                _senderPartyIdentifierTypeHeaderName.Name,
                                _senderPartyIdentifierTypeHeaderName.Namespace,
                                _senderPartyIdentifierType));


            msg.Headers.Add(MessageHeader.CreateHeader(
                                _receiverPartyIdentifierHeaderName.Name,
                                _receiverPartyIdentifierHeaderName.Namespace,
                                _receiverPartyIdentifier));

            msg.Headers.Add(MessageHeader.CreateHeader(
                                _receiverPartyIdentifierTypeHeaderName.Name,
                                _receiverPartyIdentifierTypeHeaderName.Namespace,
                                _receiverPartyIdentifierType));
        }
コード例 #2
0
 public override void InterceptRequest(dk.gov.oiosi.extension.wcf.Interceptor.Channels.InterceptorMessage interceptorMessage)
 {
     try {
         Console.WriteLine("{0} : Sent: {1} to '{2}'", DateTime.Now, interceptorMessage.GetHeaders().Action, interceptorMessage.GetHeaders().To);
     }
     catch (Exception e) {
         Console.WriteLine("Console.WriteLine Interceptor failed: " + e);
     }
 }
コード例 #3
0
        /// <summary>
        /// The method is nor operational right now because there is no need
        /// for a response interception on the response side in the current model.
        /// </summary>
        /// <param name="wcfMessage">The incoming System.ServiceModel.Channels.Message that contains the request</param>
        /// <returns></returns>
        private Message InterceptResponse(Message wcfMessage)
        {
            if (wcfMessage == null)
            {
                return(wcfMessage);
            }
            if (!_channelInterceptor.DoesResponseIntercept)
            {
                return(wcfMessage);
            }
            InterceptorMessage message = new InterceptorMessage(wcfMessage);

            _channelInterceptor.InterceptResponse(message);
            return(message.GetMessage());
        }
コード例 #4
0
        private RequestContext EndReceiveRequest(RequestContext innerContext)
        {
            RequestContext requestContext = null;

            if (innerContext == null)
            {
                requestContext = null;
            }
            else if (innerContext.RequestMessage == null)
            {
                requestContext = innerContext;
            }
            else if (!_channelInterceptor.DoesRequestIntercept)
            {
                requestContext = innerContext;
            }
            else
            {
                Message wcfMessage = innerContext.RequestMessage;
                // RequestContext wrappedContext;
                InterceptorMessage message = new InterceptorMessage(wcfMessage);
                try
                {
                    this._channelInterceptor.InterceptRequest(message);
                    requestContext = new InterceptorRequestContext(innerContext, message.GetMessage(), _channelInterceptor);
                }
                catch (InterceptorChannelException iifex)
                {
                    WCFLogger.Write(System.Diagnostics.TraceEventType.Warning, "Exception occurred in interceptor");
                    requestContext = this.HandleException(iifex, innerContext, message);
                }
                catch (Exception ex)
                {
                    WCFLogger.Write(System.Diagnostics.TraceEventType.Warning, "Exception occurred in interceptor");
                    InterceptorInternalFailureException iifex = new InterceptorInternalFailureException(ex);
                    requestContext = this.HandleException(iifex, innerContext, message);
                }
            }

            return(requestContext);
        }
コード例 #5
0
        /// <summary>
        /// The method is not functinal right now becuase there is no
        /// need for response interception in the current model
        /// </summary>
        /// <param name="wcfMessage">The request System.ServiceModel.Channels.Message to be transmitted</param>
        /// <returns>response interception</returns>
        private Message InterceptResponse(Message wcfMessage)
        {
            Message message;

            if (wcfMessage == null)
            {
                message = null;
            }
            else if (!this.channelInterceptor.DoesResponseIntercept)
            {
                WCFLogger.Write(TraceEventType.Information, "Interceptor ignored response");
                message = wcfMessage;
            }
            else
            {
                InterceptorMessage interceptorMessage = new InterceptorMessage(wcfMessage);
                this.channelInterceptor.InterceptResponse(interceptorMessage);
                message = interceptorMessage.GetMessage();
            }

            return(message);
        }
コード例 #6
0
        /// <summary>
        /// If an exception is thrown it will not be caugth by the method but it will
        /// propegate back and stop the sending of the request.
        /// </summary>
        /// <param name="wcfMessage">The request System.ServiceModel.Channels.Message to be transmitted</param>
        /// <returns>the intercepted message</returns>
        private Message InterceptRequest(Message wcfMessage)
        {
            Message interceptedWcfMessage = null;

            if (wcfMessage == null)
            {
                interceptedWcfMessage = null;
            }
            else if (!this.channelInterceptor.DoesRequestIntercept)
            {
                WCFLogger.Write(TraceEventType.Information, "Interceptor ignored request");
                interceptedWcfMessage = wcfMessage;
            }
            else
            {
                InterceptorMessage message = new InterceptorMessage(wcfMessage);
                this.channelInterceptor.InterceptRequest(message);
                interceptedWcfMessage = message.GetMessage();
            }

            return(interceptedWcfMessage);
        }
コード例 #7
0
        private void SendSoapFault(InterceptorChannelException ex, RequestContext innerContext, InterceptorMessage message)
        {
            WCFLogger.Write(System.Diagnostics.TraceEventType.Start, "Interceptor is sending a SOAP fault...");
            MessageFault messageFault = ex.GetMessageFault();
            Message      wcfMessage   = Message.CreateMessage(MessageVersion.Default, messageFault, common.Definitions.DefaultOiosiNamespace2007 + messageFault.Code.SubCode.Name);

            innerContext.Reply(wcfMessage);
            WCFLogger.Write(System.Diagnostics.TraceEventType.Stop, "Interceptor finished sending the SOAP fault.");
        }
コード例 #8
0
        private RequestContext HandleException(InterceptorChannelException icex, RequestContext innerContext, InterceptorMessage message)
        {
            RequestContext requestContext;

            WCFLogger.Write(System.Diagnostics.TraceEventType.Start, "Interceptor is starting to handle a thrown exception...");
            try {
                if (_channelInterceptor.DoesFaultOnRequestException)
                {
                    this.SendSoapFault(icex, innerContext, message);
                    requestContext = null;
                }
                else
                {
                    RequestContext wrappedContext = new InterceptorRequestContext(innerContext, message.GetMessage(), _channelInterceptor);
                    object         exceptions     = null;
                    InterceptorChannelExceptionCollection exceptionCollection = null;
                    if (!wrappedContext.RequestMessage.Properties.TryGetValue("Exceptions", out exceptions))
                    {
                        exceptions = new InterceptorChannelExceptionCollection();
                        wrappedContext.RequestMessage.Properties.Add("Exceptions", exceptions);
                    }
                    exceptionCollection = (InterceptorChannelExceptionCollection)exceptions;
                    exceptionCollection.Add(icex);
                    WCFLogger.Write(System.Diagnostics.TraceEventType.Information, "Interceptor added an exception to the message: " + icex.Message);
                    WCFLogger.Write(System.Diagnostics.TraceEventType.Stop, "Interceptor is finished handling the thrown exception.");
                    requestContext = wrappedContext;
                }
            }
            catch (Exception ex)
            {
                WCFLogger.Write(System.Diagnostics.TraceEventType.Error, "An error occurred when trying to handle an exception in the Interceptor: " + ex);
                WCFLogger.Write(System.Diagnostics.TraceEventType.Stop, "Interceptor is finished handling the thrown exception.");
                requestContext = null;
            }

            return(requestContext);
        }
コード例 #9
0
 public override void InterceptResponse(dk.gov.oiosi.extension.wcf.Interceptor.Channels.InterceptorMessage interceptorMessage)
 {
     throw new NotImplementedException();
 }