protected override WsrmFault ProcessRequestorResponse(ReliableRequestor requestor, string requestName, WsrmMessageInfo info)
        {
            string faultReason      = System.ServiceModel.SR.GetString("ReceivedResponseBeforeRequestFaultString", new object[] { requestName });
            string exceptionMessage = System.ServiceModel.SR.GetString("ReceivedResponseBeforeRequestExceptionString", new object[] { requestName });

            return(SequenceTerminatedFault.CreateProtocolFault(base.ReliableSession.OutputID, faultReason, exceptionMessage));
        }
コード例 #2
0
        protected override WsrmFault ProcessRequestorResponse(ReliableRequestor requestor, string requestName, WsrmMessageInfo info)
        {
            string faultString     = SR.Format(SR.ReceivedResponseBeforeRequestFaultString, requestName);
            string exceptionString = SR.Format(SR.ReceivedResponseBeforeRequestExceptionString, requestName);

            return(SequenceTerminatedFault.CreateProtocolFault(ReliableSession.OutputID, faultString, exceptionString));
        }
コード例 #3
0
        public static WsrmFault ValidateTerminateSequenceResponse(ChannelReliableSession session, UniqueId messageId, WsrmMessageInfo info, long last)
        {
            string exceptionMessage = null;
            string faultReason      = null;

            if (info.WsrmHeaderFault is UnknownSequenceFault)
            {
                return(null);
            }
            if (info.TerminateSequenceResponseInfo == null)
            {
                exceptionMessage = System.ServiceModel.SR.GetString("InvalidWsrmResponseSessionFaultedExceptionString", new object[] { "TerminateSequence", info.Action, "http://docs.oasis-open.org/ws-rx/wsrm/200702/TerminateSequenceResponse" });
                faultReason      = System.ServiceModel.SR.GetString("InvalidWsrmResponseSessionFaultedFaultString", new object[] { "TerminateSequence", info.Action, "http://docs.oasis-open.org/ws-rx/wsrm/200702/TerminateSequenceResponse" });
            }
            else if (!object.Equals(messageId, info.TerminateSequenceResponseInfo.RelatesTo))
            {
                exceptionMessage = System.ServiceModel.SR.GetString("WsrmMessageWithWrongRelatesToExceptionString", new object[] { "TerminateSequence" });
                faultReason      = System.ServiceModel.SR.GetString("WsrmMessageWithWrongRelatesToFaultString", new object[] { "TerminateSequence" });
            }
            else
            {
                return(ValidateFinalAck(session, info, last));
            }
            return(SequenceTerminatedFault.CreateProtocolFault(session.OutputID, faultReason, exceptionMessage));
        }
コード例 #4
0
 protected override WsrmFault VerifySimplexProtocolElements(WsrmMessageInfo info)
 {
     if ((info.AcknowledgementInfo != null) && (info.AcknowledgementInfo.SequenceID != base.OutputID))
     {
         return(new UnknownSequenceFault(info.AcknowledgementInfo.SequenceID));
     }
     if (info.AckRequestedInfo != null)
     {
         return(SequenceTerminatedFault.CreateProtocolFault(base.OutputID, System.ServiceModel.SR.GetString("SequenceTerminatedUnexpectedAckRequested"), System.ServiceModel.SR.GetString("UnexpectedAckRequested")));
     }
     if (info.CreateSequenceInfo != null)
     {
         return(SequenceTerminatedFault.CreateProtocolFault(base.OutputID, System.ServiceModel.SR.GetString("SequenceTerminatedUnexpectedCS"), System.ServiceModel.SR.GetString("UnexpectedCS")));
     }
     if (info.SequencedMessageInfo != null)
     {
         return(new UnknownSequenceFault(info.SequencedMessageInfo.SequenceID));
     }
     if (info.TerminateSequenceInfo != null)
     {
         if (base.Settings.ReliableMessagingVersion == ReliableMessagingVersion.WSReliableMessagingFebruary2005)
         {
             return(SequenceTerminatedFault.CreateProtocolFault(base.OutputID, System.ServiceModel.SR.GetString("SequenceTerminatedUnexpectedTerminateSequence"), System.ServiceModel.SR.GetString("UnexpectedTerminateSequence")));
         }
         if (info.TerminateSequenceInfo.Identifier == base.OutputID)
         {
             return(null);
         }
         return(new UnknownSequenceFault(info.TerminateSequenceInfo.Identifier));
     }
     if (info.TerminateSequenceResponseInfo != null)
     {
         WsrmUtilities.AssertWsrm11(base.Settings.ReliableMessagingVersion);
         if (info.TerminateSequenceResponseInfo.Identifier == base.OutputID)
         {
             return(null);
         }
         return(new UnknownSequenceFault(info.TerminateSequenceResponseInfo.Identifier));
     }
     if (info.CloseSequenceInfo != null)
     {
         WsrmUtilities.AssertWsrm11(base.Settings.ReliableMessagingVersion);
         if (info.CloseSequenceInfo.Identifier == base.OutputID)
         {
             return(SequenceTerminatedFault.CreateProtocolFault(base.OutputID, System.ServiceModel.SR.GetString("SequenceTerminatedUnsupportedClose"), System.ServiceModel.SR.GetString("UnsupportedCloseExceptionString")));
         }
         return(new UnknownSequenceFault(info.CloseSequenceInfo.Identifier));
     }
     if (info.CloseSequenceResponseInfo == null)
     {
         return(null);
     }
     WsrmUtilities.AssertWsrm11(base.Settings.ReliableMessagingVersion);
     if (info.CloseSequenceResponseInfo.Identifier == base.OutputID)
     {
         return(null);
     }
     return(new UnknownSequenceFault(info.CloseSequenceResponseInfo.Identifier));
 }
コード例 #5
0
        public static WsrmFault ValidateFinalAckExists(ChannelReliableSession session, WsrmAcknowledgmentInfo ackInfo)
        {
            if ((ackInfo != null) && ackInfo.Final)
            {
                return(null);
            }
            string exceptionMessage = System.ServiceModel.SR.GetString("MissingFinalAckExceptionString");
            string faultReason      = System.ServiceModel.SR.GetString("SequenceTerminatedMissingFinalAck");

            return(SequenceTerminatedFault.CreateProtocolFault(session.OutputID, faultReason, exceptionMessage));
        }
 protected override WsrmFault ProcessRequestorResponse(ReliableRequestor requestor, string requestName, WsrmMessageInfo info)
 {
     if (requestor != null)
     {
         requestor.SetInfo(info);
         return(null);
     }
     else
     {
         string faultString     = SR.GetString(SR.ReceivedResponseBeforeRequestFaultString, requestName);
         string exceptionString = SR.GetString(SR.ReceivedResponseBeforeRequestExceptionString, requestName);
         return(SequenceTerminatedFault.CreateProtocolFault(this.ReliableSession.OutputID, faultString, exceptionString));
     }
 }
コード例 #7
0
 public static bool ValidateWsrmRequest(ChannelReliableSession session, WsrmRequestInfo info, IReliableChannelBinder binder, RequestContext context)
 {
     if (!(info is CloseSequenceInfo) && !(info is TerminateSequenceInfo))
     {
         throw Fx.AssertAndThrow("Method is meant for CloseSequence or TerminateSequence only.");
     }
     if (info.ReplyTo.Uri != binder.RemoteAddress.Uri)
     {
         string    faultReason      = System.ServiceModel.SR.GetString("WsrmRequestIncorrectReplyToFaultString", new object[] { info.RequestName });
         string    exceptionMessage = System.ServiceModel.SR.GetString("WsrmRequestIncorrectReplyToExceptionString", new object[] { info.RequestName });
         WsrmFault fault            = SequenceTerminatedFault.CreateProtocolFault(session.InputID, faultReason, exceptionMessage);
         session.OnLocalFault(fault.CreateException(), fault, context);
         return(false);
     }
     return(true);
 }
コード例 #8
0
        protected override WsrmFault VerifyDuplexProtocolElements(WsrmMessageInfo info)
        {
            WsrmFault fault = base.VerifyDuplexProtocolElements(info);

            if (fault != null)
            {
                return(fault);
            }
            if ((info.CreateSequenceInfo != null) && (info.CreateSequenceInfo.OfferIdentifier != base.OutputID))
            {
                return(SequenceTerminatedFault.CreateProtocolFault(base.OutputID, System.ServiceModel.SR.GetString("SequenceTerminatedUnexpectedCSOfferId"), System.ServiceModel.SR.GetString("UnexpectedCSOfferId")));
            }
            if (info.CreateSequenceResponseInfo != null)
            {
                return(SequenceTerminatedFault.CreateProtocolFault(base.OutputID, System.ServiceModel.SR.GetString("SequenceTerminatedUnexpectedCSR"), System.ServiceModel.SR.GetString("UnexpectedCSR")));
            }
            return(null);
        }
コード例 #9
0
        protected override WsrmFault VerifyDuplexProtocolElements(WsrmMessageInfo info)
        {
            WsrmFault fault = base.VerifyDuplexProtocolElements(info);

            if (fault != null)
            {
                return(fault);
            }
            else if (info.CreateSequenceInfo != null && info.CreateSequenceInfo.OfferIdentifier != this.OutputID)
            {
                return(SequenceTerminatedFault.CreateProtocolFault(this.OutputID, SR.GetString(SR.SequenceTerminatedUnexpectedCSOfferId), SR.GetString(SR.UnexpectedCSOfferId)));
            }
            else if (info.CreateSequenceResponseInfo != null)
            {
                return(SequenceTerminatedFault.CreateProtocolFault(this.OutputID, SR.GetString(SR.SequenceTerminatedUnexpectedCSR), SR.GetString(SR.UnexpectedCSR)));
            }
            else
            {
                return(null);
            }
        }
        private void ThrowIfCloseInvalid()
        {
            bool flag = false;

            if (this.listener.ReliableMessagingVersion == ReliableMessagingVersion.WSReliableMessagingFebruary2005)
            {
                if ((this.DeliveryStrategy.EnqueuedCount > 0) || (this.Connection.Ranges.Count > 1))
                {
                    flag = true;
                }
            }
            else if ((this.listener.ReliableMessagingVersion == ReliableMessagingVersion.WSReliableMessaging11) && (this.DeliveryStrategy.EnqueuedCount > 0))
            {
                flag = true;
            }
            if (flag)
            {
                WsrmFault fault = SequenceTerminatedFault.CreateProtocolFault(this.session.InputID, System.ServiceModel.SR.GetString("SequenceTerminatedSessionClosedBeforeDone"), System.ServiceModel.SR.GetString("SessionClosedBeforeDone"));
                this.session.OnLocalFault(null, fault, null);
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(fault.CreateException());
            }
        }
        void ProcessReply(Message reply, IReliableRequest request, Int64 requestSequenceNumber)
        {
            WsrmMessageInfo messageInfo = WsrmMessageInfo.Get(this.settings.MessageVersion,
                                                              this.settings.ReliableMessagingVersion, this.binder.Channel, this.binder.GetInnerSession(), reply);

            if (!this.session.ProcessInfo(messageInfo, null))
            {
                return;
            }

            if (!this.session.VerifyDuplexProtocolElements(messageInfo, null))
            {
                return;
            }

            bool wsrm11 = this.settings.ReliableMessagingVersion == ReliableMessagingVersion.WSReliableMessaging11;

            if (messageInfo.WsrmHeaderFault != null)
            {
                // Close message now, going to stop processing in all cases.
                messageInfo.Message.Close();

                if (!(messageInfo.WsrmHeaderFault is UnknownSequenceFault))
                {
                    throw Fx.AssertAndThrow("Fault must be UnknownSequence fault.");
                }

                if (this.terminateRequestor == null)
                {
                    throw Fx.AssertAndThrow("If we start getting UnknownSequence, terminateRequestor cannot be null.");
                }

                this.terminateRequestor.SetInfo(messageInfo);

                return;
            }

            if (messageInfo.AcknowledgementInfo == null)
            {
                WsrmFault fault = SequenceTerminatedFault.CreateProtocolFault(this.session.InputID,
                                                                              SR.GetString(SR.SequenceTerminatedReplyMissingAcknowledgement),
                                                                              SR.GetString(SR.ReplyMissingAcknowledgement));
                messageInfo.Message.Close();
                this.session.OnLocalFault(fault.CreateException(), fault, null);
                return;
            }

            if (wsrm11 && (messageInfo.TerminateSequenceInfo != null))
            {
                UniqueId faultId = (messageInfo.TerminateSequenceInfo.Identifier == this.session.OutputID)
                    ? this.session.InputID
                    : this.session.OutputID;

                WsrmFault fault = SequenceTerminatedFault.CreateProtocolFault(faultId,
                                                                              SR.GetString(SR.SequenceTerminatedUnsupportedTerminateSequence),
                                                                              SR.GetString(SR.UnsupportedTerminateSequenceExceptionString));
                messageInfo.Message.Close();
                this.session.OnLocalFault(fault.CreateException(), fault, null);
                return;
            }
            else if (wsrm11 && messageInfo.AcknowledgementInfo.Final)
            {
                // Close message now, going to stop processing in all cases.
                messageInfo.Message.Close();

                if (this.closeRequestor == null)
                {
                    // Remote endpoint signaled Close, this is not allowed so we fault.
                    string exceptionString = SR.GetString(SR.UnsupportedCloseExceptionString);
                    string faultString     = SR.GetString(SR.SequenceTerminatedUnsupportedClose);

                    WsrmFault fault = SequenceTerminatedFault.CreateProtocolFault(this.session.OutputID, faultString,
                                                                                  exceptionString);
                    this.session.OnLocalFault(fault.CreateException(), fault, null);
                }
                else
                {
                    WsrmFault fault = WsrmUtilities.ValidateFinalAck(this.session, messageInfo, this.connection.Last);

                    if (fault == null)
                    {
                        // Received valid final ack after sending Close, inform the close thread.
                        this.closeRequestor.SetInfo(messageInfo);
                    }
                    else
                    {
                        // Received invalid final ack after sending Close, fault.
                        this.session.OnLocalFault(fault.CreateException(), fault, null);
                    }
                }

                return;
            }

            int bufferRemaining = -1;

            if (this.settings.FlowControlEnabled)
            {
                bufferRemaining = messageInfo.AcknowledgementInfo.BufferRemaining;
            }

            // We accept no more than MaxSequenceRanges ranges to limit the serialized ack size and
            // the amount of memory taken up by the ack ranges. Since request reply uses the presence of
            // a reply as an acknowledgement we cannot call ProcessTransferred (which stops retrying the
            // request) if we intend to drop the message. This means the limit is not strict since we do
            // not check for the limit and merge the ranges atomically. The limit + the number of
            // concurrent threads is a sufficient mitigation.
            if ((messageInfo.SequencedMessageInfo != null) &&
                !ReliableInputConnection.CanMerge(messageInfo.SequencedMessageInfo.SequenceNumber, this.ranges))
            {
                messageInfo.Message.Close();
                return;
            }

            bool exitGuard = this.replyAckConsistencyGuard != null?this.replyAckConsistencyGuard.Enter() : false;

            try
            {
                this.connection.ProcessTransferred(requestSequenceNumber,
                                                   messageInfo.AcknowledgementInfo.Ranges, bufferRemaining);

                this.session.OnRemoteActivity(this.connection.Strategy.QuotaRemaining == 0);

                if (messageInfo.SequencedMessageInfo != null)
                {
                    lock (this.ThisLock)
                    {
                        this.ranges = this.ranges.MergeWith(messageInfo.SequencedMessageInfo.SequenceNumber);
                    }
                }
            }
            finally
            {
                if (exitGuard)
                {
                    this.replyAckConsistencyGuard.Exit();
                }
            }

            if (request != null)
            {
                if (WsrmUtilities.IsWsrmAction(this.settings.ReliableMessagingVersion, messageInfo.Action))
                {
                    messageInfo.Message.Close();
                    request.Set(null);
                }
                else
                {
                    request.Set(messageInfo.Message);
                }
            }

            // The termination mechanism in the TerminateSequence fails with RequestReply.
            // Since the ack ranges are updated after ProcessTransferred is called and
            // ProcessTransferred potentially signals the Termination process, this channel
            // winds up sending a message with the ack for last message missing.
            // Thus we send the termination after we update the ranges.

            if ((this.shutdownHandle != null) && this.connection.CheckForTermination())
            {
                this.shutdownHandle.Set();
            }

            if (request != null)
            {
                request.Complete();
            }
        }
コード例 #12
0
        protected async Task ProcessMessageAsync(Message message)
        {
            bool            closeMessage = true;
            WsrmMessageInfo messageInfo  = WsrmMessageInfo.Get(Settings.MessageVersion,
                                                               Settings.ReliableMessagingVersion, _binder.Channel, _binder.GetInnerSession(), message);
            bool wsrm11 = Settings.ReliableMessagingVersion == ReliableMessagingVersion.WSReliableMessaging11;

            try
            {
                if (!_session.ProcessInfo(messageInfo, null))
                {
                    closeMessage = false;
                    return;
                }

                if (!ReliableSession.VerifySimplexProtocolElements(messageInfo, null))
                {
                    closeMessage = false;
                    return;
                }

                bool final = false;

                if (messageInfo.AcknowledgementInfo != null)
                {
                    final = wsrm11 && messageInfo.AcknowledgementInfo.Final;
                    int bufferRemaining = -1;

                    if (Settings.FlowControlEnabled)
                    {
                        bufferRemaining = messageInfo.AcknowledgementInfo.BufferRemaining;
                    }

                    Connection.ProcessTransferred(messageInfo.AcknowledgementInfo.Ranges, bufferRemaining);
                }

                if (wsrm11)
                {
                    WsrmFault fault = null;

                    if (messageInfo.TerminateSequenceResponseInfo != null)
                    {
                        fault = WsrmUtilities.ValidateTerminateSequenceResponse(_session,
                                                                                _terminateRequestor.MessageId, messageInfo, Connection.Last);

                        if (fault == null)
                        {
                            fault = ProcessRequestorResponse(_terminateRequestor, WsrmFeb2005Strings.TerminateSequence, messageInfo);
                        }
                    }
                    else if (messageInfo.CloseSequenceResponseInfo != null)
                    {
                        fault = WsrmUtilities.ValidateCloseSequenceResponse(_session,
                                                                            _closeRequestor.MessageId, messageInfo, Connection.Last);

                        if (fault == null)
                        {
                            fault = ProcessRequestorResponse(_closeRequestor, Wsrm11Strings.CloseSequence, messageInfo);
                        }
                    }
                    else if (messageInfo.TerminateSequenceInfo != null)
                    {
                        if (!WsrmUtilities.ValidateWsrmRequest(_session, messageInfo.TerminateSequenceInfo, _binder, null))
                        {
                            return;
                        }

                        WsrmAcknowledgmentInfo ackInfo = messageInfo.AcknowledgementInfo;
                        fault = WsrmUtilities.ValidateFinalAckExists(_session, ackInfo);

                        if ((fault == null) && !Connection.IsFinalAckConsistent(ackInfo.Ranges))
                        {
                            fault = new InvalidAcknowledgementFault(_session.OutputID, ackInfo.Ranges);
                        }

                        if (fault == null)
                        {
                            Message response = WsrmUtilities.CreateTerminateResponseMessage(
                                Settings.MessageVersion,
                                messageInfo.TerminateSequenceInfo.MessageId,
                                _session.OutputID);

                            try
                            {
                                await OnConnectionSendAsync(response, DefaultSendTimeout, false, true);
                            }
                            finally
                            {
                                response.Close();
                            }

                            _session.OnRemoteFault(new ProtocolException(SR.UnsupportedTerminateSequenceExceptionString));
                            return;
                        }
                    }
                    else if (final)
                    {
                        if (_closeRequestor == null)
                        {
                            string exceptionString = SR.UnsupportedCloseExceptionString;
                            string faultString     = SR.SequenceTerminatedUnsupportedClose;

                            fault = SequenceTerminatedFault.CreateProtocolFault(_session.OutputID, faultString,
                                                                                exceptionString);
                        }
                        else
                        {
                            fault = WsrmUtilities.ValidateFinalAck(_session, messageInfo, Connection.Last);

                            if (fault == null)
                            {
                                _closeRequestor.SetInfo(messageInfo);
                            }
                        }
                    }
                    else if (messageInfo.WsrmHeaderFault != null)
                    {
                        if (!(messageInfo.WsrmHeaderFault is UnknownSequenceFault))
                        {
                            throw Fx.AssertAndThrow("Fault must be UnknownSequence fault.");
                        }

                        if (_terminateRequestor == null)
                        {
                            throw Fx.AssertAndThrow("In wsrm11, if we start getting UnknownSequence, terminateRequestor cannot be null.");
                        }

                        _terminateRequestor.SetInfo(messageInfo);
                    }

                    if (fault != null)
                    {
                        _session.OnLocalFault(fault.CreateException(), fault, null);
                        return;
                    }
                }

                _session.OnRemoteActivity(Connection.Strategy.QuotaRemaining == 0);
            }
            finally
            {
                if (closeMessage)
                {
                    messageInfo.Message.Close();
                }
            }
        }
コード例 #13
0
        protected override WsrmFault VerifySimplexProtocolElements(WsrmMessageInfo info)
        {
            if (info.AcknowledgementInfo != null)
            {
                return(SequenceTerminatedFault.CreateProtocolFault(this.InputID, SR.GetString(SR.SequenceTerminatedUnexpectedAcknowledgement), SR.GetString(SR.UnexpectedAcknowledgement)));
            }
            else if (info.AckRequestedInfo != null && info.AckRequestedInfo.SequenceID != this.InputID)
            {
                return(new UnknownSequenceFault(info.AckRequestedInfo.SequenceID));
            }
            else if (info.CreateSequenceResponseInfo != null)
            {
                return(SequenceTerminatedFault.CreateProtocolFault(this.InputID, SR.GetString(SR.SequenceTerminatedUnexpectedCSR), SR.GetString(SR.UnexpectedCSR)));
            }
            else if (info.SequencedMessageInfo != null && info.SequencedMessageInfo.SequenceID != this.InputID)
            {
                return(new UnknownSequenceFault(info.SequencedMessageInfo.SequenceID));
            }
            else if (info.TerminateSequenceInfo != null && info.TerminateSequenceInfo.Identifier != this.InputID)
            {
                return(new UnknownSequenceFault(info.TerminateSequenceInfo.Identifier));
            }
            else if (info.TerminateSequenceResponseInfo != null)
            {
                WsrmUtilities.AssertWsrm11(this.Settings.ReliableMessagingVersion);

                if (info.TerminateSequenceResponseInfo.Identifier == this.InputID)
                {
                    return(SequenceTerminatedFault.CreateProtocolFault(this.InputID, SR.GetString(SR.SequenceTerminatedUnexpectedTerminateSequenceResponse), SR.GetString(SR.UnexpectedTerminateSequenceResponse)));
                }
                else
                {
                    return(new UnknownSequenceFault(info.TerminateSequenceResponseInfo.Identifier));
                }
            }
            else if (info.CloseSequenceInfo != null)
            {
                WsrmUtilities.AssertWsrm11(this.Settings.ReliableMessagingVersion);

                if (info.CloseSequenceInfo.Identifier == this.InputID)
                {
                    return(null);
                }
                else
                {
                    return(new UnknownSequenceFault(info.CloseSequenceInfo.Identifier));
                }
            }
            else if (info.CloseSequenceResponseInfo != null)
            {
                WsrmUtilities.AssertWsrm11(this.Settings.ReliableMessagingVersion);

                if (info.CloseSequenceResponseInfo.Identifier == this.InputID)
                {
                    return(SequenceTerminatedFault.CreateProtocolFault(this.InputID, SR.GetString(SR.SequenceTerminatedUnexpectedCloseSequenceResponse), SR.GetString(SR.UnexpectedCloseSequenceResponse)));
                }
                else
                {
                    return(new UnknownSequenceFault(info.CloseSequenceResponseInfo.Identifier));
                }
            }
            else
            {
                return(null);
            }
        }
        private void ProcessRequest(RequestContext context, WsrmMessageInfo info)
        {
            bool flag  = true;
            bool flag2 = true;

            try
            {
                EndpointAddress address;
                bool            flag3;
                if (!base.ReliableSession.ProcessInfo(info, context))
                {
                    flag  = false;
                    flag2 = false;
                    return;
                }
                if (!base.ReliableSession.VerifySimplexProtocolElements(info, context))
                {
                    flag  = false;
                    flag2 = false;
                    return;
                }
                base.ReliableSession.OnRemoteActivity(false);
                if (info.CreateSequenceInfo == null)
                {
                    goto Label_0104;
                }
                if (WsrmUtilities.ValidateCreateSequence <IInputSessionChannel>(info, base.Listener, base.Binder.Channel, out address))
                {
                    Message response = WsrmUtilities.CreateCreateSequenceResponse(base.Listener.MessageVersion, base.Listener.ReliableMessagingVersion, false, info.CreateSequenceInfo, base.Listener.Ordered, base.ReliableSession.InputID, address);
                    using (context)
                    {
                        using (response)
                        {
                            if (base.Binder.AddressResponse(info.Message, response))
                            {
                                context.Reply(response, base.DefaultSendTimeout);
                            }
                        }
                        goto Label_00FB;
                    }
                }
                base.ReliableSession.OnLocalFault(info.FaultException, info.FaultReply, context);
Label_00FB:
                flag  = false;
                flag2 = false;
                return;

Label_0104:
                flag3 = false;
                bool      allAdded = false;
                bool      flag5    = false;
                WsrmFault fault    = null;
                Message   message2 = null;
                Exception e        = null;
                bool      flag6    = base.Listener.ReliableMessagingVersion == ReliableMessagingVersion.WSReliableMessagingFebruary2005;
                bool      flag7    = base.Listener.ReliableMessagingVersion == ReliableMessagingVersion.WSReliableMessaging11;
                bool      flag8    = info.AckRequestedInfo != null;
                if (info.SequencedMessageInfo != null)
                {
                    lock (base.ThisLock)
                    {
                        if (base.Aborted || (base.State == CommunicationState.Faulted))
                        {
                            return;
                        }
                        long sequenceNumber = info.SequencedMessageInfo.SequenceNumber;
                        bool isLast         = flag6 && info.SequencedMessageInfo.LastMessage;
                        if (!base.Connection.IsValid(sequenceNumber, isLast))
                        {
                            if (flag6)
                            {
                                fault = new LastMessageNumberExceededFault(base.ReliableSession.InputID);
                            }
                            else
                            {
                                message2 = new SequenceClosedFault(base.ReliableSession.InputID).CreateMessage(base.Listener.MessageVersion, base.Listener.ReliableMessagingVersion);
                                if (PerformanceCounters.PerformanceCountersEnabled)
                                {
                                    PerformanceCounters.MessageDropped(base.perfCounterId);
                                }
                            }
                        }
                        else if (base.Connection.Ranges.Contains(sequenceNumber))
                        {
                            if (PerformanceCounters.PerformanceCountersEnabled)
                            {
                                PerformanceCounters.MessageDropped(base.perfCounterId);
                            }
                        }
                        else if (flag6 && (info.Action == "http://schemas.xmlsoap.org/ws/2005/02/rm/LastMessage"))
                        {
                            base.Connection.Merge(sequenceNumber, isLast);
                            allAdded = base.Connection.AllAdded;
                        }
                        else if (base.State == CommunicationState.Closing)
                        {
                            if (flag6)
                            {
                                fault = SequenceTerminatedFault.CreateProtocolFault(base.ReliableSession.InputID, System.ServiceModel.SR.GetString("SequenceTerminatedSessionClosedBeforeDone"), System.ServiceModel.SR.GetString("SessionClosedBeforeDone"));
                            }
                            else
                            {
                                message2 = new SequenceClosedFault(base.ReliableSession.InputID).CreateMessage(base.Listener.MessageVersion, base.Listener.ReliableMessagingVersion);
                                if (PerformanceCounters.PerformanceCountersEnabled)
                                {
                                    PerformanceCounters.MessageDropped(base.perfCounterId);
                                }
                            }
                        }
                        else if (base.DeliveryStrategy.CanEnqueue(sequenceNumber) && (base.Listener.Ordered || base.Connection.CanMerge(sequenceNumber)))
                        {
                            base.Connection.Merge(sequenceNumber, isLast);
                            flag3    = base.DeliveryStrategy.Enqueue(info.Message, sequenceNumber);
                            allAdded = base.Connection.AllAdded;
                            flag2    = false;
                        }
                        else if (PerformanceCounters.PerformanceCountersEnabled)
                        {
                            PerformanceCounters.MessageDropped(base.perfCounterId);
                        }
                        goto Label_05CE;
                    }
                }
                if (flag6 && (info.TerminateSequenceInfo != null))
                {
                    bool flag11;
                    lock (base.ThisLock)
                    {
                        flag11 = !base.Connection.Terminate();
                    }
                    if (!flag11)
                    {
                        return;
                    }
                    fault = SequenceTerminatedFault.CreateProtocolFault(base.ReliableSession.InputID, System.ServiceModel.SR.GetString("SequenceTerminatedEarlyTerminateSequence"), System.ServiceModel.SR.GetString("EarlyTerminateSequence"));
                }
                else if (flag7 && ((info.TerminateSequenceInfo != null) || (info.CloseSequenceInfo != null)))
                {
                    bool            flag13 = info.TerminateSequenceInfo != null;
                    WsrmRequestInfo info2  = flag13 ? ((WsrmRequestInfo)info.TerminateSequenceInfo) : ((WsrmRequestInfo)info.CloseSequenceInfo);
                    long            last   = flag13 ? info.TerminateSequenceInfo.LastMsgNumber : info.CloseSequenceInfo.LastMsgNumber;
                    if (!WsrmUtilities.ValidateWsrmRequest(base.ReliableSession, info2, base.Binder, context))
                    {
                        flag2 = false;
                        flag  = false;
                        return;
                    }
                    bool isLastLargeEnough = true;
                    bool flag15            = true;
                    lock (base.ThisLock)
                    {
                        if (!base.Connection.IsLastKnown)
                        {
                            if (flag13)
                            {
                                if (base.Connection.SetTerminateSequenceLast(last, out isLastLargeEnough))
                                {
                                    allAdded = true;
                                }
                                else if (isLastLargeEnough)
                                {
                                    e = new ProtocolException(System.ServiceModel.SR.GetString("EarlyTerminateSequence"));
                                }
                            }
                            else
                            {
                                allAdded          = base.Connection.SetCloseSequenceLast(last);
                                isLastLargeEnough = allAdded;
                            }
                            if (allAdded)
                            {
                                base.ReliableSession.SetFinalAck(base.Connection.Ranges);
                                base.DeliveryStrategy.Dispose();
                            }
                        }
                        else
                        {
                            flag15 = last == base.Connection.Last;
                            if ((flag13 && flag15) && base.Connection.IsSequenceClosed)
                            {
                                flag5 = true;
                            }
                        }
                    }
                    if (!isLastLargeEnough)
                    {
                        fault = SequenceTerminatedFault.CreateProtocolFault(base.ReliableSession.InputID, System.ServiceModel.SR.GetString("SequenceTerminatedSmallLastMsgNumber"), System.ServiceModel.SR.GetString("SmallLastMsgNumberExceptionString"));
                    }
                    else if (!flag15)
                    {
                        fault = SequenceTerminatedFault.CreateProtocolFault(base.ReliableSession.InputID, System.ServiceModel.SR.GetString("SequenceTerminatedInconsistentLastMsgNumber"), System.ServiceModel.SR.GetString("InconsistentLastMsgNumberExceptionString"));
                    }
                    else
                    {
                        message2 = flag13 ? WsrmUtilities.CreateTerminateResponseMessage(base.Listener.MessageVersion, info2.MessageId, base.ReliableSession.InputID) : WsrmUtilities.CreateCloseSequenceResponse(base.Listener.MessageVersion, info2.MessageId, base.ReliableSession.InputID);
                        flag8    = true;
                    }
                }
Label_05CE:
                if (fault != null)
                {
                    base.ReliableSession.OnLocalFault(fault.CreateException(), fault, context);
                    flag2 = false;
                    flag  = false;
                }
                else
                {
                    if ((message2 != null) && flag8)
                    {
                        base.AddAcknowledgementHeader(message2);
                    }
                    else if (message2 == null)
                    {
                        message2 = base.CreateAcknowledgmentMessage();
                    }
                    using (message2)
                    {
                        context.Reply(message2);
                    }
                    if (flag5)
                    {
                        lock (base.ThisLock)
                        {
                            base.Connection.Terminate();
                        }
                    }
                    if (e != null)
                    {
                        base.ReliableSession.OnRemoteFault(e);
                    }
                    else
                    {
                        if (flag3)
                        {
                            base.Dispatch();
                        }
                        if (allAdded)
                        {
                            ActionItem.Schedule(new Action <object>(this.ShutdownCallback), null);
                        }
                    }
                }
            }
            finally
            {
                if (flag2)
                {
                    info.Message.Close();
                }
                if (flag)
                {
                    context.Close();
                }
            }
        }
コード例 #15
0
        protected virtual WsrmFault VerifyDuplexProtocolElements(WsrmMessageInfo info)
        {
            if (info.AcknowledgementInfo != null && info.AcknowledgementInfo.SequenceID != this.OutputID)
            {
                return(new UnknownSequenceFault(info.AcknowledgementInfo.SequenceID));
            }
            else if (info.AckRequestedInfo != null && info.AckRequestedInfo.SequenceID != this.InputID)
            {
                return(new UnknownSequenceFault(info.AckRequestedInfo.SequenceID));
            }
            else if (info.SequencedMessageInfo != null && info.SequencedMessageInfo.SequenceID != this.InputID)
            {
                return(new UnknownSequenceFault(info.SequencedMessageInfo.SequenceID));
            }
            else if (info.TerminateSequenceInfo != null && info.TerminateSequenceInfo.Identifier != this.InputID)
            {
                if (this.Settings.ReliableMessagingVersion == ReliableMessagingVersion.WSReliableMessagingFebruary2005)
                {
                    return(SequenceTerminatedFault.CreateProtocolFault(this.OutputID, SR.GetString(SR.SequenceTerminatedUnexpectedTerminateSequence), SR.GetString(SR.UnexpectedTerminateSequence)));
                }
                else if (info.TerminateSequenceInfo.Identifier == this.OutputID)
                {
                    return(null);
                }
                else
                {
                    return(new UnknownSequenceFault(info.TerminateSequenceInfo.Identifier));
                }
            }
            else if (info.TerminateSequenceResponseInfo != null)
            {
                WsrmUtilities.AssertWsrm11(this.settings.ReliableMessagingVersion);

                if (info.TerminateSequenceResponseInfo.Identifier == this.OutputID)
                {
                    return(null);
                }
                else
                {
                    return(new UnknownSequenceFault(info.TerminateSequenceResponseInfo.Identifier));
                }
            }
            else if (info.CloseSequenceInfo != null)
            {
                WsrmUtilities.AssertWsrm11(this.settings.ReliableMessagingVersion);

                if (info.CloseSequenceInfo.Identifier == this.InputID)
                {
                    return(null);
                }
                else if (info.CloseSequenceInfo.Identifier == this.OutputID)
                {
                    // Spec allows RM-Destination close, but we do not.
                    return(SequenceTerminatedFault.CreateProtocolFault(this.OutputID, SR.GetString(SR.SequenceTerminatedUnsupportedClose), SR.GetString(SR.UnsupportedCloseExceptionString)));
                }
                else
                {
                    return(new UnknownSequenceFault(info.CloseSequenceInfo.Identifier));
                }
            }
            else if (info.CloseSequenceResponseInfo != null)
            {
                WsrmUtilities.AssertWsrm11(this.settings.ReliableMessagingVersion);

                if (info.CloseSequenceResponseInfo.Identifier == this.OutputID)
                {
                    return(null);
                }
                else if (info.CloseSequenceResponseInfo.Identifier == this.InputID)
                {
                    return(SequenceTerminatedFault.CreateProtocolFault(this.InputID, SR.GetString(SR.SequenceTerminatedUnexpectedCloseSequenceResponse), SR.GetString(SR.UnexpectedCloseSequenceResponse)));
                }
                else
                {
                    return(new UnknownSequenceFault(info.CloseSequenceResponseInfo.Identifier));
                }
            }
            else
            {
                return(null);
            }
        }
        private void ProcessReply(Message reply, IReliableRequest request, long requestSequenceNumber)
        {
            WsrmMessageInfo info = WsrmMessageInfo.Get(this.settings.MessageVersion, this.settings.ReliableMessagingVersion, this.binder.Channel, this.binder.GetInnerSession(), reply);

            if (this.session.ProcessInfo(info, null) && this.session.VerifyDuplexProtocolElements(info, null))
            {
                bool flag = this.settings.ReliableMessagingVersion == ReliableMessagingVersion.WSReliableMessaging11;
                if (info.WsrmHeaderFault != null)
                {
                    info.Message.Close();
                    if (!(info.WsrmHeaderFault is UnknownSequenceFault))
                    {
                        throw Fx.AssertAndThrow("Fault must be UnknownSequence fault.");
                    }
                    if (this.terminateRequestor == null)
                    {
                        throw Fx.AssertAndThrow("If we start getting UnknownSequence, terminateRequestor cannot be null.");
                    }
                    this.terminateRequestor.SetInfo(info);
                }
                else if (info.AcknowledgementInfo == null)
                {
                    WsrmFault fault = SequenceTerminatedFault.CreateProtocolFault(this.session.InputID, System.ServiceModel.SR.GetString("SequenceTerminatedReplyMissingAcknowledgement"), System.ServiceModel.SR.GetString("ReplyMissingAcknowledgement"));
                    info.Message.Close();
                    this.session.OnLocalFault(fault.CreateException(), fault, null);
                }
                else if (flag && (info.TerminateSequenceInfo != null))
                {
                    UniqueId  sequenceID = (info.TerminateSequenceInfo.Identifier == this.session.OutputID) ? this.session.InputID : this.session.OutputID;
                    WsrmFault fault2     = SequenceTerminatedFault.CreateProtocolFault(sequenceID, System.ServiceModel.SR.GetString("SequenceTerminatedUnsupportedTerminateSequence"), System.ServiceModel.SR.GetString("UnsupportedTerminateSequenceExceptionString"));
                    info.Message.Close();
                    this.session.OnLocalFault(fault2.CreateException(), fault2, null);
                }
                else if (flag && info.AcknowledgementInfo.Final)
                {
                    info.Message.Close();
                    if (this.closeRequestor == null)
                    {
                        string    exceptionMessage = System.ServiceModel.SR.GetString("UnsupportedCloseExceptionString");
                        string    faultReason      = System.ServiceModel.SR.GetString("SequenceTerminatedUnsupportedClose");
                        WsrmFault fault3           = SequenceTerminatedFault.CreateProtocolFault(this.session.OutputID, faultReason, exceptionMessage);
                        this.session.OnLocalFault(fault3.CreateException(), fault3, null);
                    }
                    else
                    {
                        WsrmFault fault4 = WsrmUtilities.ValidateFinalAck(this.session, info, this.connection.Last);
                        if (fault4 == null)
                        {
                            this.closeRequestor.SetInfo(info);
                        }
                        else
                        {
                            this.session.OnLocalFault(fault4.CreateException(), fault4, null);
                        }
                    }
                }
                else
                {
                    int quotaRemaining = -1;
                    if (this.settings.FlowControlEnabled)
                    {
                        quotaRemaining = info.AcknowledgementInfo.BufferRemaining;
                    }
                    if ((info.SequencedMessageInfo != null) && !ReliableInputConnection.CanMerge(info.SequencedMessageInfo.SequenceNumber, this.ranges))
                    {
                        info.Message.Close();
                    }
                    else
                    {
                        bool flag2 = (this.replyAckConsistencyGuard != null) ? this.replyAckConsistencyGuard.Enter() : false;
                        try
                        {
                            this.connection.ProcessTransferred(requestSequenceNumber, info.AcknowledgementInfo.Ranges, quotaRemaining);
                            this.session.OnRemoteActivity(this.connection.Strategy.QuotaRemaining == 0);
                            if (info.SequencedMessageInfo != null)
                            {
                                lock (base.ThisLock)
                                {
                                    this.ranges = this.ranges.MergeWith(info.SequencedMessageInfo.SequenceNumber);
                                }
                            }
                        }
                        finally
                        {
                            if (flag2)
                            {
                                this.replyAckConsistencyGuard.Exit();
                            }
                        }
                        if (request != null)
                        {
                            if (WsrmUtilities.IsWsrmAction(this.settings.ReliableMessagingVersion, info.Action))
                            {
                                info.Message.Close();
                                request.Set(null);
                            }
                            else
                            {
                                request.Set(info.Message);
                            }
                        }
                        if ((this.shutdownHandle != null) && this.connection.CheckForTermination())
                        {
                            this.shutdownHandle.Set();
                        }
                        if (request != null)
                        {
                            request.Complete();
                        }
                    }
                }
            }
        }
コード例 #17
0
        void ProcessCreateSequenceResponse(Message response, DateTime start)
        {
            CreateSequenceResponseInfo createResponse = null;

            using (response)
            {
                if (response.IsFault)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(WsrmUtilities.CreateCSFaultException(
                                                                                  this.Settings.MessageVersion, this.Settings.ReliableMessagingVersion, response,
                                                                                  this.binder.Channel));
                }
                else
                {
                    WsrmMessageInfo info = WsrmMessageInfo.Get(this.Settings.MessageVersion,
                                                               this.Settings.ReliableMessagingVersion, this.binder.Channel, this.binder.GetInnerSession(),
                                                               response, true);

                    if (info.ParsingException != null)
                    {
                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ProtocolException(SR.GetString(SR.UnparsableCSResponse), info.ParsingException));
                    }

                    // this throws and sends a fault if something is wrong with the info
                    this.ProcessInfo(info, null, true);
                    createResponse = info.CreateSequenceResponseInfo;

                    string exceptionReason = null;
                    string faultReason     = null;

                    if (createResponse == null)
                    {
                        exceptionReason = SR.GetString(SR.InvalidWsrmResponseChannelNotOpened,
                                                       WsrmFeb2005Strings.CreateSequence, info.Action,
                                                       WsrmIndex.GetCreateSequenceResponseActionString(this.Settings.ReliableMessagingVersion));
                    }
                    else if (!object.Equals(createResponse.RelatesTo, this.requestor.MessageId))
                    {
                        exceptionReason = SR.GetString(SR.WsrmMessageWithWrongRelatesToExceptionString, WsrmFeb2005Strings.CreateSequence);
                        faultReason     = SR.GetString(SR.WsrmMessageWithWrongRelatesToFaultString, WsrmFeb2005Strings.CreateSequence);
                    }
                    else if ((createResponse.AcceptAcksTo == null) && (this.InputID != null))
                    {
                        if (this.Settings.ReliableMessagingVersion == ReliableMessagingVersion.WSReliableMessagingFebruary2005)
                        {
                            exceptionReason = SR.GetString(SR.CSResponseWithoutOffer);
                            faultReason     = SR.GetString(SR.CSResponseWithoutOfferReason);
                        }
                        else if (this.Settings.ReliableMessagingVersion == ReliableMessagingVersion.WSReliableMessaging11)
                        {
                            exceptionReason = SR.GetString(SR.CSResponseOfferRejected);
                            faultReason     = SR.GetString(SR.CSResponseOfferRejectedReason);
                        }
                        else
                        {
                            throw Fx.AssertAndThrow("Reliable messaging version not supported.");
                        }
                    }
                    else if ((createResponse.AcceptAcksTo != null) && (this.InputID == null))
                    {
                        exceptionReason = SR.GetString(SR.CSResponseWithOffer);
                        faultReason     = SR.GetString(SR.CSResponseWithOfferReason);
                    }
                    else if (createResponse.AcceptAcksTo != null && (createResponse.AcceptAcksTo.Uri != this.binder.RemoteAddress.Uri))
                    {
                        exceptionReason = SR.GetString(SR.AcksToMustBeSameAsRemoteAddress);
                        faultReason     = SR.GetString(SR.AcksToMustBeSameAsRemoteAddressReason);
                    }

                    if ((faultReason != null) && (createResponse != null))
                    {
                        UniqueId  sequenceId = createResponse.Identifier;
                        WsrmFault fault      = SequenceTerminatedFault.CreateProtocolFault(sequenceId, faultReason, null);
                        this.OnLocalFault(null, fault, null);
                    }

                    if (exceptionReason != null)
                    {
                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ProtocolException(exceptionReason));
                    }
                }
            }

            this.InitiationTime = DateTime.UtcNow - start;
            this.OutputID       = createResponse.Identifier;
            this.pollingTimer.Set(this.GetPollingInterval());
            base.StartInactivityTimer();
        }
コード例 #18
0
        public bool ProcessInfo(WsrmMessageInfo info, RequestContext context, bool throwException)
        {
            Exception faultException;

            if (info.ParsingException != null)
            {
                WsrmFault fault;
                if (this.SequenceID != null)
                {
                    string faultReason = System.ServiceModel.SR.GetString("CouldNotParseWithAction", new object[] { info.Action });
                    fault = SequenceTerminatedFault.CreateProtocolFault(this.SequenceID, faultReason, null);
                }
                else
                {
                    fault = null;
                }
                faultException = new ProtocolException(System.ServiceModel.SR.GetString("MessageExceptionOccurred"), info.ParsingException);
                this.OnLocalFault(throwException ? null : faultException, fault, context);
            }
            else if (info.FaultReply != null)
            {
                faultException = info.FaultException;
                this.OnLocalFault(throwException ? null : faultException, info.FaultReply, context);
            }
            else if (((info.WsrmHeaderFault != null) && (info.WsrmHeaderFault.SequenceID != this.InputID)) && (info.WsrmHeaderFault.SequenceID != this.OutputID))
            {
                faultException = new ProtocolException(System.ServiceModel.SR.GetString("WrongIdentifierFault", new object[] { FaultException.GetSafeReasonText(info.WsrmHeaderFault.Reason) }));
                this.OnLocalFault(throwException ? null : faultException, (Message)null, context);
            }
            else
            {
                if (info.FaultInfo == null)
                {
                    return(true);
                }
                if (this.isSessionClosed)
                {
                    UnknownSequenceFault faultInfo = info.FaultInfo as UnknownSequenceFault;
                    if (faultInfo != null)
                    {
                        UniqueId sequenceID = faultInfo.SequenceID;
                        if (((this.OutputID != null) && (this.OutputID == sequenceID)) || ((this.InputID != null) && (this.InputID == sequenceID)))
                        {
                            if (this.settings.ReliableMessagingVersion == ReliableMessagingVersion.WSReliableMessagingFebruary2005)
                            {
                                info.Message.Close();
                                return(false);
                            }
                            if (this.settings.ReliableMessagingVersion != ReliableMessagingVersion.WSReliableMessaging11)
                            {
                                throw Fx.AssertAndThrow("Unknown version.");
                            }
                            return(true);
                        }
                    }
                }
                faultException = info.FaultException;
                if (context != null)
                {
                    context.Close();
                }
                this.OnRemoteFault(throwException ? null : faultException);
            }
            info.Message.Close();
            if (throwException)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(faultException);
            }
            return(false);
        }
        protected void ProcessMessage(Message message)
        {
            bool            flag  = true;
            WsrmMessageInfo info  = WsrmMessageInfo.Get(this.settings.MessageVersion, this.settings.ReliableMessagingVersion, this.binder.Channel, this.binder.GetInnerSession(), message);
            bool            flag2 = this.settings.ReliableMessagingVersion == ReliableMessagingVersion.WSReliableMessaging11;

            try
            {
                if (!this.session.ProcessInfo(info, null))
                {
                    flag = false;
                    return;
                }
                if (!this.ReliableSession.VerifySimplexProtocolElements(info, null))
                {
                    flag = false;
                    return;
                }
                bool flag3 = false;
                if (info.AcknowledgementInfo != null)
                {
                    flag3 = flag2 && info.AcknowledgementInfo.Final;
                    int quotaRemaining = -1;
                    if (this.settings.FlowControlEnabled)
                    {
                        quotaRemaining = info.AcknowledgementInfo.BufferRemaining;
                    }
                    this.connection.ProcessTransferred(info.AcknowledgementInfo.Ranges, quotaRemaining);
                }
                if (!flag2)
                {
                    goto Label_0300;
                }
                WsrmFault fault = null;
                if (info.TerminateSequenceResponseInfo != null)
                {
                    fault = WsrmUtilities.ValidateTerminateSequenceResponse(this.session, this.terminateRequestor.MessageId, info, this.connection.Last);
                    if (fault == null)
                    {
                        fault = this.ProcessRequestorResponse(this.terminateRequestor, "TerminateSequence", info);
                    }
                }
                else if (info.CloseSequenceResponseInfo != null)
                {
                    fault = WsrmUtilities.ValidateCloseSequenceResponse(this.session, this.closeRequestor.MessageId, info, this.connection.Last);
                    if (fault == null)
                    {
                        fault = this.ProcessRequestorResponse(this.closeRequestor, "CloseSequence", info);
                    }
                }
                else
                {
                    if (info.TerminateSequenceInfo != null)
                    {
                        if (WsrmUtilities.ValidateWsrmRequest(this.session, info.TerminateSequenceInfo, this.binder, null))
                        {
                            WsrmAcknowledgmentInfo acknowledgementInfo = info.AcknowledgementInfo;
                            fault = WsrmUtilities.ValidateFinalAckExists(this.session, acknowledgementInfo);
                            if ((fault == null) && !this.connection.IsFinalAckConsistent(acknowledgementInfo.Ranges))
                            {
                                fault = new InvalidAcknowledgementFault(this.session.OutputID, acknowledgementInfo.Ranges);
                            }
                            if (fault != null)
                            {
                                goto Label_02E5;
                            }
                            Message message2 = WsrmUtilities.CreateTerminateResponseMessage(this.settings.MessageVersion, info.TerminateSequenceInfo.MessageId, this.session.OutputID);
                            try
                            {
                                this.OnConnectionSend(message2, base.DefaultSendTimeout, false, true);
                            }
                            finally
                            {
                                message2.Close();
                            }
                            this.session.OnRemoteFault(new ProtocolException(System.ServiceModel.SR.GetString("UnsupportedTerminateSequenceExceptionString")));
                        }
                        return;
                    }
                    if (flag3)
                    {
                        if (this.closeRequestor == null)
                        {
                            string exceptionMessage = System.ServiceModel.SR.GetString("UnsupportedCloseExceptionString");
                            string faultReason      = System.ServiceModel.SR.GetString("SequenceTerminatedUnsupportedClose");
                            fault = SequenceTerminatedFault.CreateProtocolFault(this.session.OutputID, faultReason, exceptionMessage);
                        }
                        else
                        {
                            fault = WsrmUtilities.ValidateFinalAck(this.session, info, this.connection.Last);
                            if (fault == null)
                            {
                                this.closeRequestor.SetInfo(info);
                            }
                        }
                    }
                    else if (info.WsrmHeaderFault != null)
                    {
                        if (!(info.WsrmHeaderFault is UnknownSequenceFault))
                        {
                            throw Fx.AssertAndThrow("Fault must be UnknownSequence fault.");
                        }
                        if (this.terminateRequestor == null)
                        {
                            throw Fx.AssertAndThrow("In wsrm11, if we start getting UnknownSequence, terminateRequestor cannot be null.");
                        }
                        this.terminateRequestor.SetInfo(info);
                    }
                }
Label_02E5:
                if (fault != null)
                {
                    this.session.OnLocalFault(fault.CreateException(), fault, null);
                    return;
                }
Label_0300:
                this.session.OnRemoteActivity(this.connection.Strategy.QuotaRemaining == 0);
            }
            finally
            {
                if (flag)
                {
                    info.Message.Close();
                }
            }
        }
コード例 #20
0
        private void ProcessCreateSequenceResponse(Message response, DateTime start)
        {
            CreateSequenceResponseInfo createSequenceResponseInfo = null;

            using (response)
            {
                if (response.IsFault)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(WsrmUtilities.CreateCSFaultException(base.Settings.MessageVersion, base.Settings.ReliableMessagingVersion, response, this.binder.Channel));
                }
                WsrmMessageInfo info2 = WsrmMessageInfo.Get(base.Settings.MessageVersion, base.Settings.ReliableMessagingVersion, this.binder.Channel, this.binder.GetInnerSession(), response, true);
                if (info2.ParsingException != null)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ProtocolException(System.ServiceModel.SR.GetString("UnparsableCSResponse"), info2.ParsingException));
                }
                base.ProcessInfo(info2, null, true);
                createSequenceResponseInfo = info2.CreateSequenceResponseInfo;
                string message     = null;
                string faultReason = null;
                if (createSequenceResponseInfo == null)
                {
                    message = System.ServiceModel.SR.GetString("InvalidWsrmResponseChannelNotOpened", new object[] { "CreateSequence", info2.Action, WsrmIndex.GetCreateSequenceResponseActionString(base.Settings.ReliableMessagingVersion) });
                }
                else if (!object.Equals(createSequenceResponseInfo.RelatesTo, this.requestor.MessageId))
                {
                    message     = System.ServiceModel.SR.GetString("WsrmMessageWithWrongRelatesToExceptionString", new object[] { "CreateSequence" });
                    faultReason = System.ServiceModel.SR.GetString("WsrmMessageWithWrongRelatesToFaultString", new object[] { "CreateSequence" });
                }
                else if ((createSequenceResponseInfo.AcceptAcksTo == null) && (base.InputID != null))
                {
                    if (base.Settings.ReliableMessagingVersion != ReliableMessagingVersion.WSReliableMessagingFebruary2005)
                    {
                        if (base.Settings.ReliableMessagingVersion != ReliableMessagingVersion.WSReliableMessaging11)
                        {
                            throw Fx.AssertAndThrow("Reliable messaging version not supported.");
                        }
                        message     = System.ServiceModel.SR.GetString("CSResponseOfferRejected");
                        faultReason = System.ServiceModel.SR.GetString("CSResponseOfferRejectedReason");
                    }
                    else
                    {
                        message     = System.ServiceModel.SR.GetString("CSResponseWithoutOffer");
                        faultReason = System.ServiceModel.SR.GetString("CSResponseWithoutOfferReason");
                    }
                }
                else if ((createSequenceResponseInfo.AcceptAcksTo != null) && (base.InputID == null))
                {
                    message     = System.ServiceModel.SR.GetString("CSResponseWithOffer");
                    faultReason = System.ServiceModel.SR.GetString("CSResponseWithOfferReason");
                }
                else if ((createSequenceResponseInfo.AcceptAcksTo != null) && (createSequenceResponseInfo.AcceptAcksTo.Uri != this.binder.RemoteAddress.Uri))
                {
                    message     = System.ServiceModel.SR.GetString("AcksToMustBeSameAsRemoteAddress");
                    faultReason = System.ServiceModel.SR.GetString("AcksToMustBeSameAsRemoteAddressReason");
                }
                if ((faultReason != null) && (createSequenceResponseInfo != null))
                {
                    WsrmFault fault = SequenceTerminatedFault.CreateProtocolFault(createSequenceResponseInfo.Identifier, faultReason, null);
                    base.OnLocalFault(null, fault, null);
                }
                if (message != null)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ProtocolException(message));
                }
            }
            base.InitiationTime = (TimeSpan)(DateTime.UtcNow - start);
            base.OutputID       = createSequenceResponseInfo.Identifier;
            this.pollingTimer.Set(this.GetPollingInterval());
            base.StartInactivityTimer();
        }