public static WsrmFault ValidateFinalAck(ChannelReliableSession session, WsrmMessageInfo info, long last) { WsrmAcknowledgmentInfo acknowledgementInfo = info.AcknowledgementInfo; WsrmFault fault = ValidateFinalAckExists(session, acknowledgementInfo); if (fault != null) { return(fault); } SequenceRangeCollection ranges = acknowledgementInfo.Ranges; if (last == 0L) { if (ranges.Count == 0) { return(null); } } else if (ranges.Count == 1) { SequenceRange range = ranges[0]; if (range.Lower == 1L) { SequenceRange range2 = ranges[0]; if (range2.Upper == last) { return(null); } } } return(new InvalidAcknowledgementFault(session.OutputID, acknowledgementInfo.Ranges)); }
private void ProcessCloseOrTerminateReply(bool close, Message reply) { if (reply == null) { throw Fx.AssertAndThrow("Argument reply cannot be null."); } ReliableRequestor requestor = close ? this.closeRequestor : this.terminateRequestor; if (requestor.GetInfo() == null) { try { WsrmMessageInfo info = WsrmMessageInfo.Get(this.Settings.MessageVersion, this.Settings.ReliableMessagingVersion, this.binder.Channel, this.binder.GetInnerSession(), reply); this.ReliableSession.ProcessInfo(info, null, true); this.ReliableSession.VerifyDuplexProtocolElements(info, null, true); WsrmFault fault = close ? WsrmUtilities.ValidateCloseSequenceResponse(this.session, requestor.MessageId, info, this.connection.Last) : WsrmUtilities.ValidateTerminateSequenceResponse(this.session, requestor.MessageId, info, this.connection.Last); if (fault != null) { this.ReliableSession.OnLocalFault(null, fault, null); throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(fault.CreateException()); } } finally { reply.Close(); } } }
public void OnLocalFault(Exception e, WsrmFault fault, RequestContext context) { Message faultMessage = (fault == null) ? null : fault.CreateMessage(this.settings.MessageVersion, this.settings.ReliableMessagingVersion); this.OnLocalFault(e, faultMessage, context); }
public virtual void Abort() { this.guard.Abort(); this.inactivityTimer.Abort(); // Try to send a fault. bool sendFault; lock (this.ThisLock) { // Faulted thread already cleaned up. No need to to anything more. if (this.faulted == SessionFaultState.CleanedUp) { return; } // Can only send a fault if the other side did not send one already. sendFault = this.canSendFault && (this.faulted != SessionFaultState.RemotelyFaulted); // NotFaulted || LocallyFaulted this.faulted = SessionFaultState.CleanedUp; } if (sendFault) { if ((this.binder.State == CommunicationState.Opened) && this.binder.Connected && (this.binder.CanSendAsynchronously || (this.replyFaultContext != null))) { if (this.terminatingFault == null) { UniqueId sequenceId = this.InputID ?? this.OutputID; if (sequenceId != null) { WsrmFault fault = SequenceTerminatedFault.CreateCommunicationFault(sequenceId, SR.GetString(SR.SequenceTerminatedOnAbort), null); this.terminatingFault = fault.CreateMessage(this.settings.MessageVersion, this.settings.ReliableMessagingVersion); } } if (this.terminatingFault != null) { this.AddFinalRanges(); this.faultHelper.SendFaultAsync(this.binder, this.replyFaultContext, this.terminatingFault); return; } } } // Got here so the session did not actually send a fault, must clean up resources. if (this.terminatingFault != null) { this.terminatingFault.Close(); } if (this.replyFaultContext != null) { this.replyFaultContext.Abort(); } this.binder.Abort(); }
void RaiseFault(Exception faultException, WsrmFault fault) { ComponentFaultedHandler handler = this.Faulted; if (handler != null) { handler(faultException, fault); } }
private void RaiseFault(Exception faultException, WsrmFault fault) { ComponentFaultedHandler faulted = this.Faulted; if (faulted != null) { faulted(faultException, fault); } }
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); }
public bool VerifyDuplexProtocolElements(WsrmMessageInfo info, RequestContext context, bool throwException) { WsrmFault fault = this.VerifyDuplexProtocolElements(info); if (fault == null) { return(true); } if (throwException) { Exception exception = fault.CreateException(); this.OnLocalFault(null, fault, context); throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(exception); } this.OnLocalFault(fault.CreateException(), fault, context); return(false); }
private void ProcessCloseOrTerminateReply(bool close, Message reply) { if (reply == null) { throw Fx.AssertAndThrow("Argument reply cannot be null."); } ReliableMessagingVersion reliableMessagingVersion = this.settings.ReliableMessagingVersion; if (reliableMessagingVersion == ReliableMessagingVersion.WSReliableMessagingFebruary2005) { if (close) { throw Fx.AssertAndThrow("Close does not exist in Feb2005."); } reply.Close(); } else { if (reliableMessagingVersion == ReliableMessagingVersion.WSReliableMessaging11) { if (this.closeRequestor.GetInfo() != null) { return; } try { WsrmMessageInfo info = WsrmMessageInfo.Get(this.settings.MessageVersion, reliableMessagingVersion, this.binder.Channel, this.binder.GetInnerSession(), reply); this.session.ProcessInfo(info, null, true); this.session.VerifyDuplexProtocolElements(info, null, true); WsrmFault fault = close ? WsrmUtilities.ValidateCloseSequenceResponse(this.session, this.closeRequestor.MessageId, info, this.connection.Last) : WsrmUtilities.ValidateTerminateSequenceResponse(this.session, this.terminateRequestor.MessageId, info, this.connection.Last); if (fault != null) { this.session.OnLocalFault(null, fault, null); throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(fault.CreateException()); } return; } finally { reply.Close(); } } throw Fx.AssertAndThrow("Reliable messaging version not supported."); } }
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); }
private void ProcessCloseOrTerminateReply(bool close, Message reply) { if (reply == null) { // In the close case, the requestor is configured to throw TimeoutException instead of returning null. // In the terminate case, this value can be null, but the caller should not call this method. throw Fx.AssertAndThrow("Argument reply cannot be null."); } ReliableRequestor requestor = close ? _closeRequestor : _terminateRequestor; WsrmMessageInfo info = requestor.GetInfo(); // Some other thread has verified and cleaned up the reply, no more work to do. if (info != null) { return; } try { info = WsrmMessageInfo.Get(Settings.MessageVersion, Settings.ReliableMessagingVersion, _binder.Channel, _binder.GetInnerSession(), reply); ReliableSession.ProcessInfo(info, null, true); ReliableSession.VerifyDuplexProtocolElements(info, null, true); WsrmFault fault = close ? WsrmUtilities.ValidateCloseSequenceResponse(_session, requestor.MessageId, info, Connection.Last) : WsrmUtilities.ValidateTerminateSequenceResponse(_session, requestor.MessageId, info, Connection.Last); if (fault != null) { ReliableSession.OnLocalFault(null, fault, null); throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(fault.CreateException()); } } finally { reply.Close(); } }
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()); } }
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(); } } }
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(); }
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(); } }
void OnComponentFaulted(Exception faultException, WsrmFault fault) { this.session.OnLocalFault(faultException, fault, null); }
public WsrmSequenceFaultHeader(ReliableMessagingVersion reliableMessagingVersion, WsrmFault fault) : base(reliableMessagingVersion) { this.fault = fault; }
public void OnRemoteFault(WsrmFault fault) { this.OnRemoteFault(WsrmFault.CreateException(fault)); }
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(); }
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(); } } }
public async Task <Message> ReceiveReplyAsync(TimeoutHelper timeoutHelper) { bool throwing = true; try { bool expired = false; if (!_completed) { bool wait = false; lock (ThisLock) { if (!_completed) { wait = true; _tcs = new TaskCompletionSource <object>(TaskCreationOptions.RunContinuationsAsynchronously); } } if (wait) { expired = !await TaskHelpers.AwaitWithTimeout(_tcs.Task, timeoutHelper.RemainingTime()); lock (ThisLock) { if (!_completed) { _completed = true; } else { expired = false; } } } } if (_aborted) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(_parent.CreateClosedException()); } else if (_faulted) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(_parent.GetTerminalException()); } else if (expired) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new TimeoutException(SR.Format(SR.TimeoutOnRequest, _originalTimeout))); } else { throwing = false; return(_reply); } } finally { if (throwing) { WsrmFault fault = SequenceTerminatedFault.CreateCommunicationFault(_parent.session.InputID, SR.SequenceTerminatedReliableRequestThrew, null); _parent.session.OnLocalFault(null, fault, null); } } }
public static CommunicationException CreateException(WsrmFault fault) { return(fault.CreateException()); }
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(); } } } } }
public Message WaitForReply(TimeSpan timeout) { bool throwing = true; try { bool expired = false; if (!this.completed) { bool wait = false; lock (this.ThisLock) { if (!this.completed) { wait = true; this.completedHandle = new ManualResetEvent(false); } } if (wait) { expired = !TimeoutHelper.WaitOne(this.completedHandle, timeout); lock (this.ThisLock) { if (!this.completed) { this.completed = true; } else { expired = false; } } this.completedHandle.Close(); } } if (this.aborted) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(this.parent.CreateClosedException()); } else if (this.faulted) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(this.parent.GetTerminalException()); } else if (expired) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new TimeoutException(SR.GetString(SR.TimeoutOnRequest, this.originalTimeout))); } else { throwing = false; return(this.reply); } } finally { if (throwing) { WsrmFault fault = SequenceTerminatedFault.CreateCommunicationFault(this.parent.session.InputID, SR.GetString(SR.SequenceTerminatedReliableRequestThrew), null); this.parent.session.OnLocalFault(null, fault, null); if (this.completedHandle != null) { this.completedHandle.Close(); } } } }
public Message WaitForReply(TimeSpan timeout) { Message reply; bool flag = true; try { bool flag2 = false; if (!this.completed) { bool flag3 = false; lock (this.ThisLock) { if (!this.completed) { flag3 = true; this.completedHandle = new ManualResetEvent(false); } } if (flag3) { flag2 = !TimeoutHelper.WaitOne(this.completedHandle, timeout); lock (this.ThisLock) { if (!this.completed) { this.completed = true; } else { flag2 = false; } } this.completedHandle.Close(); } } if (this.aborted) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(this.parent.CreateClosedException()); } if (this.faulted) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(this.parent.GetTerminalException()); } if (flag2) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new TimeoutException(System.ServiceModel.SR.GetString("TimeoutOnRequest", new object[] { this.originalTimeout }))); } flag = false; reply = this.reply; } finally { if (flag) { WsrmFault fault = SequenceTerminatedFault.CreateCommunicationFault(this.parent.session.InputID, System.ServiceModel.SR.GetString("SequenceTerminatedReliableRequestThrew"), null); this.parent.session.OnLocalFault(null, fault, null); if (this.completedHandle != null) { this.completedHandle.Close(); } } } return(reply); }
void ProcessCloseOrTerminateReply(bool close, Message reply) { if (reply == null) { // In the close case, the requestor is configured to throw TimeoutException instead of returning null. // In the terminate case, this value can be null, but the caller should not call this method. throw Fx.AssertAndThrow("Argument reply cannot be null."); } ReliableMessagingVersion reliableMessagingVersion = this.settings.ReliableMessagingVersion; if (reliableMessagingVersion == ReliableMessagingVersion.WSReliableMessagingFebruary2005) { if (close) { throw Fx.AssertAndThrow("Close does not exist in Feb2005."); } reply.Close(); } else if (reliableMessagingVersion == ReliableMessagingVersion.WSReliableMessaging11) { WsrmMessageInfo info = this.closeRequestor.GetInfo(); // Close - Final ack made it. // Terminate - UnknownSequence. // Either way, message has been verified and does not belong to this thread. if (info != null) { return; } try { info = WsrmMessageInfo.Get(this.settings.MessageVersion, reliableMessagingVersion, this.binder.Channel, this.binder.GetInnerSession(), reply); this.session.ProcessInfo(info, null, true); this.session.VerifyDuplexProtocolElements(info, null, true); WsrmFault fault = close ? WsrmUtilities.ValidateCloseSequenceResponse(this.session, this.closeRequestor.MessageId, info, this.connection.Last) : WsrmUtilities.ValidateTerminateSequenceResponse(this.session, this.terminateRequestor.MessageId, info, this.connection.Last); if (fault != null) { this.session.OnLocalFault(null, fault, null); throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(fault.CreateException()); } } finally { reply.Close(); } } else { throw Fx.AssertAndThrow("Reliable messaging version not supported."); } }
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(); } } }
public static CommunicationException CreateException(WsrmFault fault) { return fault.CreateException(); }
void RaiseFault(Exception faultException, WsrmFault fault) { ComponentFaultedHandler handler = this.Faulted; if (handler != null) handler(faultException, fault); }
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); }