예제 #1
0
        protected override bool OnTryCreateException(Message message, MessageFault fault, out Exception exception)
        {
            if (message.Headers.Action == "http://schemas.microsoft.com/net/2005/12/windowscommunicationfoundation/transactions/fault")
            {
                exception = new ProtocolException(fault.Reason.GetMatchingTranslation(CultureInfo.CurrentCulture).Text);
                return(true);
            }
            if (fault.IsMustUnderstandFault)
            {
                MessageHeader emptyTransactionHeader = this.channel.Formatter.EmptyTransactionHeader;
                if (MessageFault.WasHeaderNotUnderstood(message.Headers, emptyTransactionHeader.Name, emptyTransactionHeader.Namespace))
                {
                    exception = new ProtocolException(System.ServiceModel.SR.GetString("SFxTransactionHeaderNotUnderstood", new object[] { emptyTransactionHeader.Name, emptyTransactionHeader.Namespace, this.channel.Protocol }));
                    return(true);
                }
            }
            FaultConverter innerProperty = this.channel.GetInnerProperty <FaultConverter>();

            if (innerProperty != null)
            {
                return(innerProperty.TryCreateException(message, fault, out exception));
            }
            exception = null;
            return(false);
        }
        public override T GetProperty <T>()
        {
            if (typeof(T) == typeof(IRequestSessionChannel))
            {
                return((T)(object)this);
            }

            if (typeof(T) == typeof(ChannelParameterCollection))
            {
                return((T)(object)this.channelParameters);
            }

            T baseProperty = base.GetProperty <T>();

            if (baseProperty != null)
            {
                return(baseProperty);
            }

            T innerProperty = this.binder.Channel.GetProperty <T>();

            if ((innerProperty == null) && (typeof(T) == typeof(FaultConverter)))
            {
                return((T)(object)FaultConverter.GetDefaultFaultConverter(this.settings.MessageVersion));
            }
            else
            {
                return(innerProperty);
            }
        }
        protected override bool OnTryCreateException(Message message, MessageFault fault, out Exception exception)
        {
            if (message.Headers.Action == FaultCodeConstants.Actions.Transactions)
            {
                exception = new ProtocolException(fault.Reason.GetMatchingTranslation(CultureInfo.CurrentCulture).Text);
                return(true);
            }

            if (fault.IsMustUnderstandFault)
            {
                MessageHeader header = this.channel.Formatter.EmptyTransactionHeader;
                if (MessageFault.WasHeaderNotUnderstood(message.Headers, header.Name, header.Namespace))
                {
                    exception = new ProtocolException(SR.GetString(SR.SFxTransactionHeaderNotUnderstood, header.Name, header.Namespace, this.channel.Protocol));
                    return(true);
                }
            }

            FaultConverter inner = this.channel.GetInnerProperty <FaultConverter>();

            if (inner != null)
            {
                return(inner.TryCreateException(message, fault, out exception));
            }
            else
            {
                exception = null;
                return(false);
            }
        }
 public virtual T GetProperty <T>() where T : class
 {
     if (typeof(T) == typeof(FaultConverter))
     {
         return((T)FaultConverter.GetDefaultFaultConverter(this.MessageVersion));
     }
     return(default(T));
 }
예제 #5
0
        public virtual T GetProperty <T>() where T : class
        {
            if (typeof(T) == typeof(FaultConverter))
            {
                return((T)(object)FaultConverter.GetDefaultFaultConverter(MessageVersion));
            }

            return(null);
        }
        public static Exception CreateCSFaultException(MessageVersion version, ReliableMessagingVersion reliableMessagingVersion, Message message, IChannel innerChannel)
        {
            FaultCode    subCode;
            Exception    exception;
            MessageFault messageFault = MessageFault.CreateFault(message, 0x10000);
            FaultCode    code         = messageFault.Code;

            if (version.Envelope == EnvelopeVersion.Soap11)
            {
                subCode = code;
            }
            else
            {
                if (version.Envelope != EnvelopeVersion.Soap12)
                {
                    throw Fx.AssertAndThrow("Unsupported version.");
                }
                subCode = code.SubCode;
            }
            if (subCode != null)
            {
                if ((subCode.Namespace == WsrmIndex.GetNamespaceString(reliableMessagingVersion)) && (subCode.Name == "CreateSequenceRefused"))
                {
                    string safeReasonText = FaultException.GetSafeReasonText(messageFault);
                    if (version.Envelope == EnvelopeVersion.Soap12)
                    {
                        FaultCode code3 = subCode.SubCode;
                        if (((code3 != null) && (code3.Namespace == "http://schemas.microsoft.com/ws/2006/05/rm")) && (code3.Name == "ConnectionLimitReached"))
                        {
                            return(new ServerTooBusyException(safeReasonText));
                        }
                        if (code.IsSenderFault)
                        {
                            return(new ProtocolException(safeReasonText));
                        }
                    }
                    return(new CommunicationException(safeReasonText));
                }
                if ((subCode.Namespace == version.Addressing.Namespace) && (subCode.Name == "EndpointUnavailable"))
                {
                    return(new EndpointNotFoundException(FaultException.GetSafeReasonText(messageFault)));
                }
            }
            FaultConverter property = innerChannel.GetProperty <FaultConverter>();

            if (property == null)
            {
                property = FaultConverter.GetDefaultFaultConverter(version);
            }
            if (property.TryCreateException(message, messageFault, out exception))
            {
                return(exception);
            }
            return(new ProtocolException(System.ServiceModel.SR.GetString("UnrecognizedFaultReceivedOnOpen", new object[] { messageFault.Code.Namespace, messageFault.Code.Name, FaultException.GetSafeReasonText(messageFault) })));
        }
예제 #7
0
        protected override bool OnTryCreateFaultMessage(Exception exception, out Message message)
        {
            FaultConverter innerProperty = this.channel.GetInnerProperty <FaultConverter>();

            if (innerProperty != null)
            {
                return(innerProperty.TryCreateFaultMessage(exception, out message));
            }
            message = null;
            return(false);
        }
예제 #8
0
 internal void ProvideFault(Exception e, FaultConverter faultConverter, ref ErrorHandlerFaultInfo faultInfo)
 {
     ProvideWellKnownFault(e, faultConverter, ref faultInfo);
     for (int i = 0; i < _handlers.Length; i++)
     {
         Message m = faultInfo.Fault;
         _handlers[i].ProvideFault(e, _messageVersion, ref m);
         faultInfo.Fault = m;
         if (TD.FaultProviderInvokedIsEnabled())
         {
             TD.FaultProviderInvoked(_handlers[i].GetType().FullName, e.Message);
         }
     }
     this.ProvideFaultOfLastResort(e, ref faultInfo);
 }
예제 #9
0
        protected override bool OnTryCreateFaultMessage(Exception exception, out Message message)
        {
            if (this.innerChannel == null)
            {
                message = null;
                return(false);
            }
            FaultConverter property = this.innerChannel.GetProperty <FaultConverter>();

            if (property != null)
            {
                return(property.TryCreateFaultMessage(exception, out message));
            }
            message = null;
            return(false);
        }
예제 #10
0
        protected override bool OnTryCreateException(Message message, MessageFault fault, out Exception exception)
        {
            if (this.innerChannel == null)
            {
                exception = null;
                return(false);
            }
            FaultConverter property = this.innerChannel.GetProperty <FaultConverter>();

            if (property != null)
            {
                return(property.TryCreateException(message, fault, out exception));
            }
            exception = null;
            return(false);
        }
        public override T GetProperty <T>() where T : class
        {
            if (typeof(T) == typeof(IInputSessionChannel))
            {
                return((T)this);
            }
            T property = base.GetProperty <T>();

            if (property != null)
            {
                return(property);
            }
            T local2 = this.binder.Channel.GetProperty <T>();

            if ((local2 == null) && (typeof(T) == typeof(FaultConverter)))
            {
                return((T)FaultConverter.GetDefaultFaultConverter(this.listener.MessageVersion));
            }
            return(local2);
        }
예제 #12
0
 public override T GetProperty <T>()
 {
     if (typeof(T) == typeof(PeerNode))
     {
         return((T)(object)this.peerNode);
     }
     else if (typeof(T) == typeof(PeerNodeImplementation))
     {
         return((T)(object)this.peerNode.InnerNode);
     }
     else if (typeof(T) == typeof(IOnlineStatus))
     {
         return((T)(object)this.peerNode);
     }
     else if (typeof(T) == typeof(FaultConverter))
     {
         return((T)(object)FaultConverter.GetDefaultFaultConverter(MessageVersion.Soap12WSAddressing10));
     }
     return(base.GetProperty <T>());
 }
예제 #13
0
 public override void Reply(Message message, TimeSpan timeout)
 {
     try {
         if (!message.IsFault && message.Headers.Action != Constants.WstIssueReplyAction)
         {
             message = SecureMessage(message);
         }
         source.Reply(message, timeout);
     } catch (Exception ex) {
         FaultConverter fc = FaultConverter.GetDefaultFaultConverter(msg.Version);
         Message        fault;
         if (fc.TryCreateFaultMessage(ex, out fault))
         {
             source.Reply(fault, timeout);
         }
         else
         {
             throw;
         }
     }
 }
예제 #14
0
 private void ProvideWellKnownFault(Exception e, FaultConverter faultConverter, ref ErrorHandlerFaultInfo faultInfo)
 {
     Message faultMessage;
     if (faultConverter != null && faultConverter.TryCreateFaultMessage(e, out faultMessage))
     {
         faultInfo.Fault = faultMessage;
         return;
     }
     else if (e is NetDispatcherFaultException)
     {
         NetDispatcherFaultException ndfe = e as NetDispatcherFaultException;
         if (_debug)
         {
             ExceptionDetail detail = new ExceptionDetail(ndfe);
             faultInfo.Fault = Message.CreateMessage(_messageVersion, MessageFault.CreateFault(ndfe.Code, ndfe.Reason, detail), ndfe.Action);
         }
         else
         {
             faultInfo.Fault = Message.CreateMessage(_messageVersion, ndfe.CreateMessageFault(), ndfe.Action);
         }
     }
 }
 private Exception DeserializeFault(System.ServiceModel.Channels.Message inMessage, FaultConverter faultConverter)
 {
     MessageFault fault = MessageFault.CreateFault(inMessage, 0x10000);
     string action = inMessage.Headers.Action;
     if (action == inMessage.Version.Addressing.DefaultFaultAction)
     {
         action = null;
     }
     Exception exception = null;
     if (faultConverter != null)
     {
         faultConverter.TryCreateException(inMessage, fault, out exception);
     }
     if (exception == null)
     {
         exception = this.FaultFormatter.Deserialize(fault, action);
     }
     if (inMessage.State != MessageState.Created)
     {
         inMessage.Close();
     }
     return exception;
 }
        public override T GetProperty <T>() where T : class
        {
            if (typeof(T) == typeof(IRequestSessionChannel))
            {
                return((T)this);
            }
            if (typeof(T) == typeof(ChannelParameterCollection))
            {
                return((T)this.channelParameters);
            }
            T property = base.GetProperty <T>();

            if (property != null)
            {
                return(property);
            }
            T local2 = this.binder.Channel.GetProperty <T>();

            if ((local2 == null) && (typeof(T) == typeof(FaultConverter)))
            {
                return((T)FaultConverter.GetDefaultFaultConverter(this.settings.MessageVersion));
            }
            return(local2);
        }
        public static WsrmMessageInfo Get(MessageVersion messageVersion, ReliableMessagingVersion reliableMessagingVersion, IChannel channel, ISession session, System.ServiceModel.Channels.Message message, bool csrOnly)
        {
            WsrmMessageInfo info = new WsrmMessageInfo {
                message = message
            };
            bool isFault = true;

            try
            {
                isFault = message.IsFault;
                MessageHeaders headers = message.Headers;
                string         action  = headers.Action;
                info.action = action;
                bool flag2 = false;
                bool flag3 = reliableMessagingVersion == ReliableMessagingVersion.WSReliableMessagingFebruary2005;
                bool flag4 = reliableMessagingVersion == ReliableMessagingVersion.WSReliableMessaging11;
                bool flag5 = false;
                if (action == WsrmIndex.GetCreateSequenceResponseActionString(reliableMessagingVersion))
                {
                    info.createSequenceResponseInfo = System.ServiceModel.Channels.CreateSequenceResponseInfo.ReadMessage(messageVersion, reliableMessagingVersion, message, headers);
                    ValidateMustUnderstand(messageVersion, message);
                    return(info);
                }
                if (csrOnly)
                {
                    return(info);
                }
                if (action == WsrmIndex.GetTerminateSequenceActionString(reliableMessagingVersion))
                {
                    info.terminateSequenceInfo = System.ServiceModel.Channels.TerminateSequenceInfo.ReadMessage(messageVersion, reliableMessagingVersion, message, headers);
                    flag2 = true;
                }
                else if (action == WsrmIndex.GetCreateSequenceActionString(reliableMessagingVersion))
                {
                    info.createSequenceInfo = System.ServiceModel.Channels.CreateSequenceInfo.ReadMessage(messageVersion, reliableMessagingVersion, session as ISecureConversationSession, message, headers);
                    if (flag3)
                    {
                        ValidateMustUnderstand(messageVersion, message);
                        return(info);
                    }
                    flag5 = true;
                }
                else if (flag4)
                {
                    if (action == "http://docs.oasis-open.org/ws-rx/wsrm/200702/CloseSequence")
                    {
                        info.closeSequenceInfo = System.ServiceModel.Channels.CloseSequenceInfo.ReadMessage(messageVersion, message, headers);
                        flag2 = true;
                    }
                    else if (action == "http://docs.oasis-open.org/ws-rx/wsrm/200702/CloseSequenceResponse")
                    {
                        info.closeSequenceResponseInfo = System.ServiceModel.Channels.CloseSequenceResponseInfo.ReadMessage(messageVersion, message, headers);
                        flag2 = true;
                    }
                    else if (action == WsrmIndex.GetTerminateSequenceResponseActionString(reliableMessagingVersion))
                    {
                        info.terminateSequenceResponseInfo = System.ServiceModel.Channels.TerminateSequenceResponseInfo.ReadMessage(messageVersion, message, headers);
                        flag2 = true;
                    }
                }
                string namespaceString = WsrmIndex.GetNamespaceString(reliableMessagingVersion);
                bool   flag6           = messageVersion.Envelope == EnvelopeVersion.Soap11;
                bool   flag7           = false;
                int    num             = -1;
                int    headerIndex     = -1;
                int    num3            = -1;
                int    num4            = -1;
                int    num5            = -1;
                int    num6            = -1;
                int    index           = -1;
                int    num8            = -1;
                int    num9            = -1;
                for (int i = 0; i < headers.Count; i++)
                {
                    MessageHeaderInfo info2 = headers[i];
                    if (messageVersion.Envelope.IsUltimateDestinationActor(info2.Actor) && (info2.Namespace == namespaceString))
                    {
                        bool flag8 = true;
                        if (flag5)
                        {
                            if (flag4 && (info2.Name == "UsesSequenceSSL"))
                            {
                                if (num8 != -1)
                                {
                                    num = i;
                                    break;
                                }
                                num8 = i;
                            }
                            else if (flag4 && (info2.Name == "UsesSequenceSTR"))
                            {
                                if (num9 != -1)
                                {
                                    num = i;
                                    break;
                                }
                                num9 = i;
                            }
                            else
                            {
                                flag8 = false;
                            }
                        }
                        else if (info2.Name == "Sequence")
                        {
                            if (headerIndex != -1)
                            {
                                num = i;
                                break;
                            }
                            headerIndex = i;
                        }
                        else if (info2.Name == "SequenceAcknowledgement")
                        {
                            if (num3 != -1)
                            {
                                num = i;
                                break;
                            }
                            num3 = i;
                        }
                        else if (info2.Name == "AckRequested")
                        {
                            if (num4 != -1)
                            {
                                num = i;
                                break;
                            }
                            num4 = i;
                        }
                        else if (flag6 && (info2.Name == "SequenceFault"))
                        {
                            if (index != -1)
                            {
                                num = i;
                                break;
                            }
                            index = i;
                        }
                        else
                        {
                            flag8 = false;
                        }
                        if (flag8)
                        {
                            if (i > num5)
                            {
                                num5 = i;
                            }
                            if (num6 == -1)
                            {
                                num6 = i;
                            }
                        }
                    }
                }
                if (num != -1)
                {
                    Collection <MessageHeaderInfo> notUnderstoodHeaders = new Collection <MessageHeaderInfo> {
                        headers[num]
                    };
                    throw System.ServiceModel.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new MustUnderstandSoapException(notUnderstoodHeaders, messageVersion.Envelope));
                }
                if (num5 > -1)
                {
                    BufferedMessage message2 = message as BufferedMessage;
                    if ((message2 != null) && message2.Headers.ContainsOnlyBufferedMessageHeaders)
                    {
                        flag7 = true;
                        using (XmlDictionaryReader reader = headers.GetReaderAtHeader(num6))
                        {
                            for (int j = num6; j <= num5; j++)
                            {
                                MessageHeaderInfo header = headers[j];
                                if (flag5)
                                {
                                    if (flag4 && (j == num8))
                                    {
                                        info.usesSequenceSSLInfo = WsrmUsesSequenceSSLInfo.ReadHeader(reader, header);
                                        headers.UnderstoodHeaders.Add(header);
                                    }
                                    else if (flag4 && (j == num9))
                                    {
                                        info.usesSequenceSTRInfo = WsrmUsesSequenceSTRInfo.ReadHeader(reader, header);
                                        headers.UnderstoodHeaders.Add(header);
                                    }
                                    else
                                    {
                                        reader.Skip();
                                    }
                                }
                                else if (j == headerIndex)
                                {
                                    info.sequencedMessageInfo = WsrmSequencedMessageInfo.ReadHeader(reliableMessagingVersion, reader, header);
                                    headers.UnderstoodHeaders.Add(header);
                                }
                                else if (j == num3)
                                {
                                    info.acknowledgementInfo = WsrmAcknowledgmentInfo.ReadHeader(reliableMessagingVersion, reader, header);
                                    headers.UnderstoodHeaders.Add(header);
                                }
                                else if (j == num4)
                                {
                                    info.ackRequestedInfo = WsrmAckRequestedInfo.ReadHeader(reliableMessagingVersion, reader, header);
                                    headers.UnderstoodHeaders.Add(header);
                                }
                                else
                                {
                                    reader.Skip();
                                }
                            }
                        }
                    }
                }
                if ((num5 > -1) && !flag7)
                {
                    flag7 = true;
                    if (flag5)
                    {
                        if (num8 != -1)
                        {
                            using (XmlDictionaryReader reader2 = headers.GetReaderAtHeader(num8))
                            {
                                MessageHeaderInfo info4 = headers[num8];
                                info.usesSequenceSSLInfo = WsrmUsesSequenceSSLInfo.ReadHeader(reader2, info4);
                                headers.UnderstoodHeaders.Add(info4);
                            }
                        }
                        if (num9 == -1)
                        {
                            goto Label_05CB;
                        }
                        using (XmlDictionaryReader reader3 = headers.GetReaderAtHeader(num9))
                        {
                            MessageHeaderInfo info5 = headers[num9];
                            info.usesSequenceSTRInfo = WsrmUsesSequenceSTRInfo.ReadHeader(reader3, info5);
                            headers.UnderstoodHeaders.Add(info5);
                            goto Label_05CB;
                        }
                    }
                    if (headerIndex != -1)
                    {
                        using (XmlDictionaryReader reader4 = headers.GetReaderAtHeader(headerIndex))
                        {
                            MessageHeaderInfo info6 = headers[headerIndex];
                            info.sequencedMessageInfo = WsrmSequencedMessageInfo.ReadHeader(reliableMessagingVersion, reader4, info6);
                            headers.UnderstoodHeaders.Add(info6);
                        }
                    }
                    if (num3 != -1)
                    {
                        using (XmlDictionaryReader reader5 = headers.GetReaderAtHeader(num3))
                        {
                            MessageHeaderInfo info7 = headers[num3];
                            info.acknowledgementInfo = WsrmAcknowledgmentInfo.ReadHeader(reliableMessagingVersion, reader5, info7);
                            headers.UnderstoodHeaders.Add(info7);
                        }
                    }
                    if (num4 != -1)
                    {
                        using (XmlDictionaryReader reader6 = headers.GetReaderAtHeader(num4))
                        {
                            MessageHeaderInfo info8 = headers[num4];
                            info.ackRequestedInfo = WsrmAckRequestedInfo.ReadHeader(reliableMessagingVersion, reader6, info8);
                            headers.UnderstoodHeaders.Add(info8);
                        }
                    }
                }
Label_05CB:
                if (flag5)
                {
                    System.ServiceModel.Channels.CreateSequenceInfo.ValidateCreateSequenceHeaders(messageVersion, session as ISecureConversationSession, info);
                    ValidateMustUnderstand(messageVersion, message);
                    return(info);
                }
                if ((info.sequencedMessageInfo == null) && (info.action == null))
                {
                    if (flag3)
                    {
                        throw System.ServiceModel.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new MessageHeaderException(System.ServiceModel.SR.GetString("NoActionNoSequenceHeaderReason"), messageVersion.Addressing.Namespace, "Action", false));
                    }
                    throw System.ServiceModel.DiagnosticUtility.ExceptionUtility.ThrowHelperError(CreateWsrmRequiredException(messageVersion));
                }
                if ((info.sequencedMessageInfo == null) && message.IsFault)
                {
                    System.ServiceModel.Channels.WsrmHeaderFault fault;
                    info.faultInfo = System.ServiceModel.Channels.MessageFault.CreateFault(message, 0x10000);
                    if (flag6)
                    {
                        if (System.ServiceModel.Channels.WsrmHeaderFault.TryCreateFault11(reliableMessagingVersion, message, info.faultInfo, index, out fault))
                        {
                            info.faultInfo      = fault;
                            info.faultException = WsrmFault.CreateException(fault);
                        }
                    }
                    else if (System.ServiceModel.Channels.WsrmHeaderFault.TryCreateFault12(reliableMessagingVersion, message, info.faultInfo, out fault))
                    {
                        info.faultInfo      = fault;
                        info.faultException = WsrmFault.CreateException(fault);
                    }
                    if (fault == null)
                    {
                        FaultConverter property = channel.GetProperty <FaultConverter>();
                        if (property == null)
                        {
                            property = FaultConverter.GetDefaultFaultConverter(messageVersion);
                        }
                        if (!property.TryCreateException(message, info.faultInfo, out info.faultException))
                        {
                            info.faultException = new ProtocolException(System.ServiceModel.SR.GetString("UnrecognizedFaultReceived", new object[] { info.faultInfo.Code.Namespace, info.faultInfo.Code.Name, System.ServiceModel.FaultException.GetSafeReasonText(info.faultInfo) }));
                        }
                    }
                    flag2 = true;
                }
                if (!flag7 && !flag2)
                {
                    if (flag3)
                    {
                        throw System.ServiceModel.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ActionNotSupportedException(System.ServiceModel.SR.GetString("NonWsrmFeb2005ActionNotSupported", new object[] { action })));
                    }
                    throw System.ServiceModel.DiagnosticUtility.ExceptionUtility.ThrowHelperError(CreateWsrmRequiredException(messageVersion));
                }
                if (!flag2 && !WsrmUtilities.IsWsrmAction(reliableMessagingVersion, action))
                {
                    return(info);
                }
                ValidateMustUnderstand(messageVersion, message);
            }
            catch (InternalFaultException exception)
            {
                if (System.ServiceModel.DiagnosticUtility.ShouldTraceInformation)
                {
                    System.ServiceModel.DiagnosticUtility.ExceptionUtility.TraceHandledException(exception, TraceEventType.Information);
                }
                info.FaultReply     = exception.FaultReply;
                info.faultException = exception.InnerException;
            }
            catch (CommunicationException exception2)
            {
                if (System.ServiceModel.DiagnosticUtility.ShouldTraceInformation)
                {
                    System.ServiceModel.DiagnosticUtility.ExceptionUtility.TraceHandledException(exception2, TraceEventType.Information);
                }
                if (isFault)
                {
                    info.parsingException = exception2;
                    return(info);
                }
                FaultConverter defaultFaultConverter = channel.GetProperty <FaultConverter>();
                if (defaultFaultConverter == null)
                {
                    defaultFaultConverter = FaultConverter.GetDefaultFaultConverter(messageVersion);
                }
                if (defaultFaultConverter.TryCreateFaultMessage(exception2, out info.faultReply))
                {
                    info.faultException = new ProtocolException(System.ServiceModel.SR.GetString("MessageExceptionOccurred"), exception2);
                    return(info);
                }
                info.parsingException = new ProtocolException(System.ServiceModel.SR.GetString("MessageExceptionOccurred"), exception2);
            }
            catch (XmlException exception3)
            {
                if (System.ServiceModel.DiagnosticUtility.ShouldTraceInformation)
                {
                    System.ServiceModel.DiagnosticUtility.ExceptionUtility.TraceHandledException(exception3, TraceEventType.Information);
                }
                info.parsingException = new ProtocolException(System.ServiceModel.SR.GetString("MessageExceptionOccurred"), exception3);
            }
            return(info);
        }
        public static bool ValidateCreateSequence <TChannel>(WsrmMessageInfo info, ReliableChannelListenerBase <TChannel> listener, IChannel channel, out EndpointAddress acksTo) where TChannel : class, IChannel
        {
            acksTo = null;
            string reason = null;

            if (info.CreateSequenceInfo.OfferIdentifier == null)
            {
                if (typeof(TChannel) == typeof(IDuplexSessionChannel))
                {
                    reason = System.ServiceModel.SR.GetString("CSRefusedDuplexNoOffer", new object[] { listener.Uri });
                }
                else if (typeof(TChannel) == typeof(IReplySessionChannel))
                {
                    reason = System.ServiceModel.SR.GetString("CSRefusedReplyNoOffer", new object[] { listener.Uri });
                }
            }
            else if ((listener.ReliableMessagingVersion == ReliableMessagingVersion.WSReliableMessagingFebruary2005) && (typeof(TChannel) == typeof(IInputSessionChannel)))
            {
                reason = System.ServiceModel.SR.GetString("CSRefusedInputOffer", new object[] { listener.Uri });
            }
            if (reason != null)
            {
                info.FaultReply     = CreateCSRefusedProtocolFault(listener.MessageVersion, listener.ReliableMessagingVersion, reason);
                info.FaultException = new ProtocolException(System.ServiceModel.SR.GetString("ConflictingOffer"));
                return(false);
            }
            if (listener.LocalAddresses != null)
            {
                Collection <EndpointAddress> results = new Collection <EndpointAddress>();
                try
                {
                    listener.LocalAddresses.GetMatchingValues(info.Message, results);
                }
                catch (CommunicationException exception)
                {
                    Message        message;
                    FaultConverter property = channel.GetProperty <FaultConverter>();
                    if (property == null)
                    {
                        property = FaultConverter.GetDefaultFaultConverter(listener.MessageVersion);
                    }
                    if (!property.TryCreateFaultMessage(exception, out message))
                    {
                        throw;
                    }
                    info.FaultReply     = message;
                    info.FaultException = new ProtocolException(System.ServiceModel.SR.GetString("MessageExceptionOccurred"), exception);
                    return(false);
                }
                if (results.Count > 0)
                {
                    EndpointAddress address = results[0];
                    acksTo = new EndpointAddress(info.CreateSequenceInfo.To, address.Identity, address.Headers);
                    return(true);
                }
                info.FaultReply     = CreateEndpointNotFoundFault(listener.MessageVersion, System.ServiceModel.SR.GetString("EndpointNotFound", new object[] { info.CreateSequenceInfo.To }));
                info.FaultException = new ProtocolException(System.ServiceModel.SR.GetString("ConflictingAddress"));
                return(false);
            }
            acksTo = new EndpointAddress(info.CreateSequenceInfo.To, new AddressHeader[0]);
            return(true);
        }
 private void ProvideWellKnownFault(Exception e, FaultConverter faultConverter, ref ErrorHandlerFaultInfo faultInfo)
 {
     Message message;
     if ((faultConverter != null) && faultConverter.TryCreateFaultMessage(e, out message))
     {
         faultInfo.Fault = message;
     }
     else if (e is NetDispatcherFaultException)
     {
         NetDispatcherFaultException exception = e as NetDispatcherFaultException;
         if (this.debug)
         {
             ExceptionDetail detail = new ExceptionDetail(exception);
             faultInfo.Fault = Message.CreateMessage(this.messageVersion, MessageFault.CreateFault(exception.Code, exception.Reason, detail), exception.Action);
         }
         else
         {
             faultInfo.Fault = Message.CreateMessage(this.messageVersion, exception.CreateMessageFault(), exception.Action);
         }
     }
 }
예제 #20
0
        Exception DeserializeFault(Message inMessage, FaultConverter faultConverter)
        {
            // Reproduce logic in ClientOperationFormatterHelper

            MessageFault messageFault = MessageFault.CreateFault(inMessage, TransportDefaults.MaxFaultSize);
            string action = inMessage.Headers.Action;
            if (action == inMessage.Version.Addressing.DefaultFaultAction)
            {
                action = null;
            }

            Exception exception = null;
            if (faultConverter != null)
            {
                faultConverter.TryCreateException(inMessage, messageFault, out exception);
            }

            if (exception == null)
            {
                exception = this.FaultFormatter.Deserialize(messageFault, action);
            }

            if (inMessage.State != MessageState.Created)
            {
                inMessage.Close();
            }

            return exception;
        }