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."); }
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); }
/// <summary> /// Adds an exception to the collection. /// </summary> /// <param name="exception">the exception to add</param> public void Add(InterceptorChannelException exception) { _exceptions.Add(exception); }