예제 #1
0
        public static string GetSubcode(XmlDictionaryReader headerReader, ReliableMessagingVersion reliableMessagingVersion)
        {
            string localName = null;

            try
            {
                string str3;
                WsrmFeb2005Dictionary dictionary   = XD.WsrmFeb2005Dictionary;
                XmlDictionaryString   namespaceUri = WsrmIndex.GetNamespace(reliableMessagingVersion);
                headerReader.ReadStartElement(dictionary.SequenceFault, namespaceUri);
                headerReader.ReadStartElement(dictionary.FaultCode, namespaceUri);
                XmlUtil.ReadContentAsQName(headerReader, out localName, out str3);
                if (str3 != WsrmIndex.GetNamespaceString(reliableMessagingVersion))
                {
                    localName = null;
                }
                headerReader.ReadEndElement();
                while (headerReader.IsStartElement())
                {
                    headerReader.Skip();
                }
                headerReader.ReadEndElement();
            }
            finally
            {
                headerReader.Close();
            }
            return(localName);
        }
예제 #2
0
        public MessageNumberRolloverFault(FaultCode code, FaultReason reason, XmlDictionaryReader detailReader,
                                          ReliableMessagingVersion reliableMessagingVersion)
            : base(code, WsrmFeb2005Strings.MessageNumberRollover, reason, true, true)
        {
            try
            {
                this.SequenceID = WsrmUtilities.ReadIdentifier(detailReader, reliableMessagingVersion);

                if (reliableMessagingVersion == ReliableMessagingVersion.WSReliableMessaging11)
                {
                    detailReader.ReadStartElement(DXD.Wsrm11Dictionary.MaxMessageNumber,
                                                  WsrmIndex.GetNamespace(reliableMessagingVersion));

                    string maxMessageNumberString = detailReader.ReadContentAsString();
                    ulong  maxMessageNumber;
                    if (!UInt64.TryParse(maxMessageNumberString, out maxMessageNumber) ||
                        (maxMessageNumber <= 0))
                    {
                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(
                                                                                      SR.GetString(SR.InvalidSequenceNumber, maxMessageNumber)));
                    }
                    // otherwise ignore value

                    detailReader.ReadEndElement();
                }
            }
            finally
            {
                detailReader.Close();
            }
        }
        private static Message CreateCSRefusedFault(MessageVersion messageVersion, ReliableMessagingVersion reliableMessagingVersion, bool isSenderFault, FaultCode subCode, string reason)
        {
            FaultCode code;

            if (messageVersion.Envelope == EnvelopeVersion.Soap11)
            {
                code = new FaultCode("CreateSequenceRefused", WsrmIndex.GetNamespaceString(reliableMessagingVersion));
            }
            else
            {
                if (messageVersion.Envelope != EnvelopeVersion.Soap12)
                {
                    throw Fx.AssertAndThrow("Unsupported version.");
                }
                if (subCode == null)
                {
                    subCode = new FaultCode("CreateSequenceRefused", WsrmIndex.GetNamespaceString(reliableMessagingVersion), subCode);
                }
                if (isSenderFault)
                {
                    code = FaultCode.CreateSenderFaultCode(subCode);
                }
                else
                {
                    code = FaultCode.CreateReceiverFaultCode(subCode);
                }
            }
            FaultReason  reason2           = new FaultReason(System.ServiceModel.SR.GetString("CSRefused", new object[] { reason }), CultureInfo.CurrentCulture);
            MessageFault fault             = MessageFault.CreateFault(code, reason2);
            string       faultActionString = WsrmIndex.GetFaultActionString(messageVersion.Addressing, reliableMessagingVersion);

            return(Message.CreateMessage(messageVersion, fault, faultActionString));
        }
        protected override void OnWriteBodyContents(XmlDictionaryWriter writer)
        {
            WsrmFeb2005Dictionary dictionary   = XD.WsrmFeb2005Dictionary;
            XmlDictionaryString   namespaceUri = WsrmIndex.GetNamespace(this.reliableMessagingVersion);

            writer.WriteStartElement(dictionary.CreateSequenceResponse, namespaceUri);
            writer.WriteStartElement(dictionary.Identifier, namespaceUri);
            writer.WriteValue(this.identifier);
            writer.WriteEndElement();
            if (this.expires.HasValue)
            {
                writer.WriteStartElement(dictionary.Expires, namespaceUri);
                writer.WriteValue(this.expires.Value);
                writer.WriteEndElement();
            }
            if (this.reliableMessagingVersion == ReliableMessagingVersion.WSReliableMessaging11)
            {
                Wsrm11Dictionary dictionary2 = DXD.Wsrm11Dictionary;
                writer.WriteStartElement(dictionary2.IncompleteSequenceBehavior, namespaceUri);
                writer.WriteValue(this.ordered ? dictionary2.DiscardFollowingFirstGap : dictionary2.NoDiscard);
                writer.WriteEndElement();
            }
            if (this.acceptAcksTo != null)
            {
                writer.WriteStartElement(dictionary.Accept, namespaceUri);
                this.acceptAcksTo.WriteTo(this.addressingVersion, writer, dictionary.AcksTo, namespaceUri);
                writer.WriteEndElement();
            }
            writer.WriteEndElement();
        }
예제 #5
0
        public static CloseSequenceInfo Create(XmlDictionaryReader reader)
        {
            if (reader == null)
            {
                Fx.Assert("Argument reader cannot be null.");
            }

            CloseSequenceInfo closeSequenceInfo = new CloseSequenceInfo();

            XmlDictionaryString wsrmNs           = WsrmIndex.GetNamespace(ReliableMessagingVersion.WSReliableMessaging11);
            Wsrm11Dictionary    wsrm11Dictionary = DXD.Wsrm11Dictionary;

            reader.ReadStartElement(wsrm11Dictionary.CloseSequence, wsrmNs);
            reader.ReadStartElement(XD.WsrmFeb2005Dictionary.Identifier, wsrmNs);
            closeSequenceInfo.Identifier = reader.ReadContentAsUniqueId();
            reader.ReadEndElement();

            if (reader.IsStartElement(wsrm11Dictionary.LastMsgNumber, wsrmNs))
            {
                reader.ReadStartElement();
                closeSequenceInfo.LastMsgNumber = WsrmUtilities.ReadSequenceNumber(reader, false);
                reader.ReadEndElement();
            }

            while (reader.IsStartElement())
            {
                reader.Skip();
            }

            reader.ReadEndElement();

            return(closeSequenceInfo);
        }
        public ClientReliableSession(ChannelBase channel, IReliableFactorySettings factory, IClientReliableChannelBinder binder, FaultHelper faultHelper, UniqueId inputID) : base(channel, factory, binder, faultHelper)
        {
            this.binder       = binder;
            base.InputID      = inputID;
            this.pollingTimer = new InterruptibleTimer(this.GetPollingInterval(), new WaitCallback(this.OnPollingTimerElapsed), null);
            if (this.binder.Channel is IRequestChannel)
            {
                this.requestor = new RequestReliableRequestor();
            }
            else if (this.binder.Channel is IDuplexChannel)
            {
                SendReceiveReliableRequestor requestor = new SendReceiveReliableRequestor {
                    TimeoutIsSafe = !this.ChannelSupportsOneCreateSequenceAttempt()
                };
                this.requestor = requestor;
            }
            MessageVersion           messageVersion           = base.Settings.MessageVersion;
            ReliableMessagingVersion reliableMessagingVersion = base.Settings.ReliableMessagingVersion;

            this.requestor.MessageVersion      = messageVersion;
            this.requestor.Binder              = this.binder;
            this.requestor.IsCreateSequence    = true;
            this.requestor.TimeoutString1Index = "TimeoutOnOpen";
            this.requestor.MessageAction       = WsrmIndex.GetCreateSequenceActionHeader(messageVersion.Addressing, reliableMessagingVersion);
            if ((reliableMessagingVersion == ReliableMessagingVersion.WSReliableMessaging11) && (this.binder.GetInnerSession() is ISecureConversationSession))
            {
                this.requestor.MessageHeader = new WsrmUsesSequenceSTRHeader();
            }
            this.requestor.MessageBody = new CreateSequence(base.Settings.MessageVersion.Addressing, reliableMessagingVersion, base.Settings.Ordered, this.binder, base.InputID);
            this.requestor.SetRequestResponsePattern();
        }
예제 #7
0
        protected override void OnWriteBodyContents(XmlDictionaryWriter writer)
        {
            WsrmFeb2005Dictionary dictionary   = XD.WsrmFeb2005Dictionary;
            XmlDictionaryString   namespaceUri = WsrmIndex.GetNamespace(this.reliableMessagingVersion);

            writer.WriteStartElement(dictionary.CreateSequence, namespaceUri);
            EndpointAddress localAddress = this.binder.LocalAddress;

            localAddress.WriteTo(this.addressingVersion, writer, dictionary.AcksTo, namespaceUri);
            if (this.offerIdentifier != null)
            {
                writer.WriteStartElement(dictionary.Offer, namespaceUri);
                writer.WriteStartElement(dictionary.Identifier, namespaceUri);
                writer.WriteValue(this.offerIdentifier);
                writer.WriteEndElement();
                if (this.reliableMessagingVersion == ReliableMessagingVersion.WSReliableMessaging11)
                {
                    Wsrm11Dictionary dictionary2 = DXD.Wsrm11Dictionary;
                    localAddress.WriteTo(this.addressingVersion, writer, dictionary2.Endpoint, namespaceUri);
                    writer.WriteStartElement(dictionary2.IncompleteSequenceBehavior, namespaceUri);
                    writer.WriteValue(this.ordered ? dictionary2.DiscardFollowingFirstGap : dictionary2.NoDiscard);
                    writer.WriteEndElement();
                }
                writer.WriteEndElement();
            }
            ISecureConversationSession innerSession = this.binder.GetInnerSession() as ISecureConversationSession;

            if (innerSession != null)
            {
                innerSession.WriteSessionTokenIdentifier(writer);
            }
            writer.WriteEndElement();
        }
예제 #8
0
        public static WsrmSequencedMessageInfo ReadHeader(ReliableMessagingVersion reliableMessagingVersion, XmlDictionaryReader reader, MessageHeaderInfo header)
        {
            WsrmFeb2005Dictionary dictionary   = XD.WsrmFeb2005Dictionary;
            XmlDictionaryString   namespaceUri = WsrmIndex.GetNamespace(reliableMessagingVersion);

            reader.ReadStartElement();
            reader.ReadStartElement(dictionary.Identifier, namespaceUri);
            UniqueId sequenceID = reader.ReadContentAsUniqueId();

            reader.ReadEndElement();
            reader.ReadStartElement(dictionary.MessageNumber, namespaceUri);
            long sequenceNumber = WsrmUtilities.ReadSequenceNumber(reader);

            reader.ReadEndElement();
            bool lastMessage = false;

            if ((reliableMessagingVersion == ReliableMessagingVersion.WSReliableMessagingFebruary2005) && reader.IsStartElement(dictionary.LastMessage, namespaceUri))
            {
                WsrmUtilities.ReadEmptyElement(reader);
                lastMessage = true;
            }
            while (reader.IsStartElement())
            {
                reader.Skip();
            }
            reader.ReadEndElement();
            return(new WsrmSequencedMessageInfo(sequenceID, sequenceNumber, lastMessage, header));
        }
        internal static Message CreateTerminateMessage(MessageVersion version, ReliableMessagingVersion reliableMessagingVersion, UniqueId id, long last)
        {
            Message message = Message.CreateMessage(version, WsrmIndex.GetTerminateSequenceActionHeader(version.Addressing, reliableMessagingVersion), new TerminateSequence(reliableMessagingVersion, id, last));

            message.Properties.AllowOutputBatching = false;
            return(message);
        }
        internal static Message CreateCSRefusedServerTooBusyFault(MessageVersion messageVersion, ReliableMessagingVersion reliableMessagingVersion, string reason)
        {
            FaultCode subCode = new FaultCode("ConnectionLimitReached", "http://schemas.microsoft.com/ws/2006/05/rm");

            subCode = new FaultCode("CreateSequenceRefused", WsrmIndex.GetNamespaceString(reliableMessagingVersion), subCode);
            return(CreateCSRefusedFault(messageVersion, reliableMessagingVersion, false, subCode, reason));
        }
        public static TerminateSequenceResponseInfo Create(XmlDictionaryReader reader)
        {
            if (reader == null)
            {
                Fx.Assert("Argument reader cannot be null.");
            }

            TerminateSequenceResponseInfo terminateSequenceInfo = new TerminateSequenceResponseInfo();
            XmlDictionaryString           wsrmNs = WsrmIndex.GetNamespace(ReliableMessagingVersion.WSReliableMessaging11);

            reader.ReadStartElement(DXD.Wsrm11Dictionary.TerminateSequenceResponse, wsrmNs);

            reader.ReadStartElement(XD.WsrmFeb2005Dictionary.Identifier, wsrmNs);
            terminateSequenceInfo.Identifier = reader.ReadContentAsUniqueId();
            reader.ReadEndElement();

            while (reader.IsStartElement())
            {
                reader.Skip();
            }

            reader.ReadEndElement();

            return(terminateSequenceInfo);
        }
예제 #12
0
        public Message CreateMessage(MessageVersion messageVersion, ReliableMessagingVersion reliableMessagingVersion)
        {
            this.SetReliableMessagingVersion(reliableMessagingVersion);
            string action = WsrmIndex.GetFaultActionString(messageVersion.Addressing, reliableMessagingVersion);

            if (messageVersion.Envelope == EnvelopeVersion.Soap11)
            {
                this.code = this.Get11Code(this.code, this.subcode);
            }
            else if (messageVersion.Envelope == EnvelopeVersion.Soap12)
            {
                if (this.code.SubCode == null)
                {
                    FaultCode subCode = new FaultCode(this.subcode,
                                                      WsrmIndex.GetNamespaceString(reliableMessagingVersion));
                    this.code = new FaultCode(this.code.Name, this.code.Namespace, subCode);
                }

                this.hasDetail = this.Get12HasDetail();
            }
            else
            {
                throw Fx.AssertAndThrow("Unsupported MessageVersion.");
            }

            Message message = Message.CreateMessage(messageVersion, this, action);

            this.OnFaultMessageCreated(messageVersion, message);
            return(message);
        }
예제 #13
0
        internal static void WriteAckRanges(XmlDictionaryWriter writer, ReliableMessagingVersion reliableMessagingVersion, UniqueId sequenceId, SequenceRangeCollection ranges)
        {
            WsrmFeb2005Dictionary dictionary   = XD.WsrmFeb2005Dictionary;
            XmlDictionaryString   namespaceUri = WsrmIndex.GetNamespace(reliableMessagingVersion);

            writer.WriteStartElement(dictionary.Identifier, namespaceUri);
            writer.WriteValue(sequenceId);
            writer.WriteEndElement();
            if (ranges.Count == 0)
            {
                if (reliableMessagingVersion == ReliableMessagingVersion.WSReliableMessagingFebruary2005)
                {
                    ranges = ranges.MergeWith((long)0L);
                }
                else if (reliableMessagingVersion == ReliableMessagingVersion.WSReliableMessaging11)
                {
                    writer.WriteStartElement(DXD.Wsrm11Dictionary.None, namespaceUri);
                    writer.WriteEndElement();
                }
            }
            for (int i = 0; i < ranges.Count; i++)
            {
                writer.WriteStartElement(dictionary.AcknowledgementRange, namespaceUri);
                writer.WriteStartAttribute(dictionary.Lower, null);
                SequenceRange range = ranges[i];
                writer.WriteValue(range.Lower);
                writer.WriteEndAttribute();
                writer.WriteStartAttribute(dictionary.Upper, null);
                SequenceRange range2 = ranges[i];
                writer.WriteValue(range2.Upper);
                writer.WriteEndAttribute();
                writer.WriteEndElement();
            }
        }
예제 #14
0
        public static bool TryCreateFault12(ReliableMessagingVersion reliableMessagingVersion, Message message,
                                            MessageFault fault, out WsrmHeaderFault wsrmFault)
        {
            // All wsrm header faults must be sender or receiver faults.
            if (!fault.Code.IsSenderFault && !fault.Code.IsReceiverFault)
            {
                wsrmFault = null;
                return(false);
            }

            if ((fault.Code.SubCode == null) ||
                (fault.Code.SubCode.Namespace != WsrmIndex.GetNamespaceString(reliableMessagingVersion)) || !fault.HasDetail)
            {
                wsrmFault = null;
                return(false);
            }

            string subcodeName = fault.Code.SubCode.Name;
            XmlDictionaryReader detailReader = fault.GetReaderAtDetailContents();

            wsrmFault = CreateWsrmHeaderFault(reliableMessagingVersion, fault.Code, subcodeName, fault.Reason,
                                              detailReader);

            return(wsrmFault != null);
        }
예제 #15
0
        static void LookupDetailInformation(ReliableMessagingVersion reliableMessagingVersion, string subcode,
                                            out string detailName, out string detailNamespace)
        {
            detailName      = null;
            detailNamespace = null;
            string wsrmNs      = WsrmIndex.GetNamespaceString(reliableMessagingVersion);
            bool   wsrmFeb2005 = reliableMessagingVersion == ReliableMessagingVersion.WSReliableMessagingFebruary2005;
            bool   wsrm11      = reliableMessagingVersion == ReliableMessagingVersion.WSReliableMessaging11;

            if (subcode == WsrmFeb2005Strings.InvalidAcknowledgement)
            {
                detailName      = WsrmFeb2005Strings.SequenceAcknowledgement;
                detailNamespace = wsrmNs;
            }
            else if ((subcode == WsrmFeb2005Strings.MessageNumberRollover) ||
                     (subcode == WsrmFeb2005Strings.SequenceTerminated) ||
                     (subcode == WsrmFeb2005Strings.UnknownSequence) ||
                     (wsrmFeb2005 && (subcode == WsrmFeb2005Strings.LastMessageNumberExceeded)) ||
                     (wsrm11 && (subcode == Wsrm11Strings.SequenceClosed)))
            {
                detailName      = WsrmFeb2005Strings.Identifier;
                detailNamespace = wsrmNs;
            }
            else
            {
                detailName      = null;
                detailNamespace = null;
            }
        }
        internal static Message CreateCloseSequenceResponse(MessageVersion messageVersion, UniqueId messageId, UniqueId inputId)
        {
            CloseSequenceResponse body = new CloseSequenceResponse(inputId);
            Message message            = Message.CreateMessage(messageVersion, WsrmIndex.GetCloseSequenceResponseActionHeader(messageVersion.Addressing), body);

            message.Headers.RelatesTo = messageId;
            return(message);
        }
        internal static Message CreateAcknowledgmentMessage(MessageVersion version, ReliableMessagingVersion reliableMessagingVersion, UniqueId id, SequenceRangeCollection ranges, bool final, int bufferRemaining)
        {
            Message message = Message.CreateMessage(version, WsrmIndex.GetSequenceAcknowledgementActionHeader(version.Addressing, reliableMessagingVersion));

            AddAcknowledgementHeader(reliableMessagingVersion, message, id, ranges, final, bufferRemaining);
            message.Properties.AllowOutputBatching = false;
            return(message);
        }
        public static UniqueId ReadIdentifier(XmlDictionaryReader reader, ReliableMessagingVersion reliableMessagingVersion)
        {
            reader.ReadStartElement(XD.WsrmFeb2005Dictionary.Identifier, WsrmIndex.GetNamespace(reliableMessagingVersion));
            UniqueId id = reader.ReadContentAsUniqueId();

            reader.ReadEndElement();
            return(id);
        }
        internal static Message CreateTerminateResponseMessage(MessageVersion version, UniqueId messageId, UniqueId sequenceId)
        {
            Message message = Message.CreateMessage(version, WsrmIndex.GetTerminateSequenceResponseActionHeader(version.Addressing), new TerminateSequenceResponse(sequenceId));

            message.Properties.AllowOutputBatching = false;
            message.Headers.RelatesTo = messageId;
            return(message);
        }
 internal static bool IsWsrmAction(ReliableMessagingVersion reliableMessagingVersion, string action)
 {
     if (action == null)
     {
         return(false);
     }
     return(action.StartsWith(WsrmIndex.GetNamespaceString(reliableMessagingVersion), StringComparison.Ordinal));
 }
        internal static Message CreateAckRequestedMessage(MessageVersion messageVersion, ReliableMessagingVersion reliableMessagingVersion, UniqueId id)
        {
            Message message = Message.CreateMessage(messageVersion, WsrmIndex.GetAckRequestedActionHeader(messageVersion.Addressing, reliableMessagingVersion));

            AddAckRequestedHeader(reliableMessagingVersion, message, id);
            message.Properties.AllowOutputBatching = false;
            return(message);
        }
        protected override void OnWriteBodyContents(XmlDictionaryWriter writer)
        {
            XmlDictionaryString wsrmNs = WsrmIndex.GetNamespace(ReliableMessagingVersion.WSReliableMessaging11);

            writer.WriteStartElement(DXD.Wsrm11Dictionary.TerminateSequenceResponse, wsrmNs);
            writer.WriteStartElement(XD.WsrmFeb2005Dictionary.Identifier, wsrmNs);
            writer.WriteValue(this.identifier);
            writer.WriteEndElement();
            writer.WriteEndElement();
        }
예제 #23
0
        protected override void OnWriteDetailContents(XmlDictionaryWriter writer)
        {
            WsrmFeb2005Dictionary    wsrmFeb2005Dictionary    = XD.WsrmFeb2005Dictionary;
            ReliableMessagingVersion reliableMessagingVersion = this.GetReliableMessagingVersion();
            XmlDictionaryString      wsrmNs = WsrmIndex.GetNamespace(reliableMessagingVersion);

            writer.WriteStartElement(wsrmFeb2005Dictionary.SequenceAcknowledgement, wsrmNs);
            WsrmAcknowledgmentHeader.WriteAckRanges(writer, reliableMessagingVersion, this.SequenceID, this.ranges);
            writer.WriteEndElement();
        }
        public static Exception CreateCSFaultException(MessageVersion version, ReliableMessagingVersion reliableMessagingVersion, Message message, IChannel innerChannel)
        {
            FaultCode    subCode;
            Exception    exception;
            MessageFault messageFault = MessageFault.CreateFault(message, 0x10000);
            FaultCode    code         = messageFault.Code;

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

            if (property == null)
            {
                property = FaultConverter.GetDefaultFaultConverter(version);
            }
            if (property.TryCreateException(message, messageFault, out exception))
            {
                return(exception);
            }
            return(new ProtocolException(System.ServiceModel.SR.GetString("UnrecognizedFaultReceivedOnOpen", new object[] { messageFault.Code.Namespace, messageFault.Code.Name, FaultException.GetSafeReasonText(messageFault) })));
        }
        protected override void OnWriteDetailContents(XmlDictionaryWriter writer)
        {
            ReliableMessagingVersion reliableMessagingVersion = base.GetReliableMessagingVersion();

            WsrmUtilities.WriteIdentifier(writer, reliableMessagingVersion, base.SequenceID);
            if (reliableMessagingVersion == ReliableMessagingVersion.WSReliableMessaging11)
            {
                writer.WriteStartElement("r", DXD.Wsrm11Dictionary.MaxMessageNumber, WsrmIndex.GetNamespace(reliableMessagingVersion));
                writer.WriteValue((long)0x7fffffffffffffffL);
                writer.WriteEndElement();
            }
        }
        private static ActionHeader GetActionHeader(AddressingVersion addressingVersion, ReliableMessagingVersion reliableMessagingVersion, string element)
        {
            WsrmIndex index = null;

            if (reliableMessagingVersion == ReliableMessagingVersion.WSReliableMessagingFebruary2005)
            {
                if (addressingVersion == AddressingVersion.WSAddressingAugust2004)
                {
                    if (wsAddressingAug2004WSReliableMessagingFeb2005 == null)
                    {
                        wsAddressingAug2004WSReliableMessagingFeb2005 = new WsrmFeb2005Index(addressingVersion);
                    }
                    index = wsAddressingAug2004WSReliableMessagingFeb2005;
                }
                else if (addressingVersion == AddressingVersion.WSAddressing10)
                {
                    if (wsAddressing10WSReliableMessagingFeb2005 == null)
                    {
                        wsAddressing10WSReliableMessagingFeb2005 = new WsrmFeb2005Index(addressingVersion);
                    }
                    index = wsAddressing10WSReliableMessagingFeb2005;
                }
            }
            else
            {
                if (reliableMessagingVersion != ReliableMessagingVersion.WSReliableMessaging11)
                {
                    throw Fx.AssertAndThrow("Reliable messaging version not supported.");
                }
                if (addressingVersion == AddressingVersion.WSAddressingAugust2004)
                {
                    if (wsAddressingAug2004WSReliableMessaging11 == null)
                    {
                        wsAddressingAug2004WSReliableMessaging11 = new Wsrm11Index(addressingVersion);
                    }
                    index = wsAddressingAug2004WSReliableMessaging11;
                }
                else if (addressingVersion == AddressingVersion.WSAddressing10)
                {
                    if (wsAddressing10WSReliableMessaging11 == null)
                    {
                        wsAddressing10WSReliableMessaging11 = new Wsrm11Index(addressingVersion);
                    }
                    index = wsAddressing10WSReliableMessaging11;
                }
            }
            if (index == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ProtocolException(System.ServiceModel.SR.GetString("AddressingVersionNotSupported", new object[] { addressingVersion })));
            }
            return(index.GetActionHeader(element));
        }
예제 #27
0
        public static WsrmAcknowledgmentInfo ReadHeader(ReliableMessagingVersion reliableMessagingVersion, XmlDictionaryReader reader, MessageHeaderInfo header)
        {
            UniqueId id;
            SequenceRangeCollection ranges;
            bool flag;
            WsrmFeb2005Dictionary dictionary   = XD.WsrmFeb2005Dictionary;
            XmlDictionaryString   namespaceUri = WsrmIndex.GetNamespace(reliableMessagingVersion);

            ReadAck(reliableMessagingVersion, reader, out id, out ranges, out flag);
            int bufferRemaining = -1;

            while (reader.IsStartElement())
            {
                if (reader.IsStartElement(dictionary.BufferRemaining, XD.WsrmFeb2005Dictionary.NETNamespace))
                {
                    if (bufferRemaining != -1)
                    {
                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(System.ServiceModel.SR.GetString("UnexpectedXmlChildNode", new object[] { reader.Name, reader.NodeType, "Body" })));
                    }
                    reader.ReadStartElement();
                    bufferRemaining = reader.ReadContentAsInt();
                    reader.ReadEndElement();
                    if (bufferRemaining < 0)
                    {
                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(System.ServiceModel.SR.GetString("InvalidBufferRemaining", new object[] { bufferRemaining })));
                    }
                }
                else
                {
                    if (reader.IsStartElement(dictionary.AcknowledgementRange, namespaceUri))
                    {
                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(System.ServiceModel.SR.GetString("UnexpectedXmlChildNode", new object[] { reader.Name, reader.NodeType, "Body" })));
                    }
                    if (reader.IsStartElement(dictionary.Nack, namespaceUri))
                    {
                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(System.ServiceModel.SR.GetString("UnexpectedXmlChildNode", new object[] { reader.Name, reader.NodeType, "Body" })));
                    }
                    if (reliableMessagingVersion == ReliableMessagingVersion.WSReliableMessaging11)
                    {
                        Wsrm11Dictionary dictionary2 = DXD.Wsrm11Dictionary;
                        if (reader.IsStartElement(dictionary2.None, namespaceUri) || reader.IsStartElement(dictionary2.Final, namespaceUri))
                        {
                            throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(System.ServiceModel.SR.GetString("UnexpectedXmlChildNode", new object[] { reader.Name, reader.NodeType, dictionary.SequenceAcknowledgement })));
                        }
                    }
                    reader.Skip();
                }
            }
            reader.ReadEndElement();
            return(new WsrmAcknowledgmentInfo(id, ranges, flag, bufferRemaining, header));
        }
예제 #28
0
        private ChannelProtectionRequirements GetProtectionRequirements()
        {
            ChannelProtectionRequirements requirements = new ChannelProtectionRequirements();
            MessagePartSpecification      signedReliabilityMessageParts = WsrmIndex.GetSignedReliabilityMessageParts(this.reliableMessagingVersion);

            requirements.IncomingSignatureParts.AddParts(signedReliabilityMessageParts);
            requirements.OutgoingSignatureParts.AddParts(signedReliabilityMessageParts);
            if (this.reliableMessagingVersion == System.ServiceModel.ReliableMessagingVersion.WSReliableMessagingFebruary2005)
            {
                ScopedMessagePartSpecification signaturePart  = requirements.IncomingSignatureParts;
                ScopedMessagePartSpecification encryptionPart = requirements.IncomingEncryptionParts;
                ProtectProtocolMessage(signaturePart, encryptionPart, "http://schemas.xmlsoap.org/ws/2005/02/rm/AckRequested");
                ProtectProtocolMessage(signaturePart, encryptionPart, "http://schemas.xmlsoap.org/ws/2005/02/rm/CreateSequence");
                ProtectProtocolMessage(signaturePart, encryptionPart, "http://schemas.xmlsoap.org/ws/2005/02/rm/SequenceAcknowledgement");
                ProtectProtocolMessage(signaturePart, encryptionPart, "http://schemas.xmlsoap.org/ws/2005/02/rm/LastMessage");
                ProtectProtocolMessage(signaturePart, encryptionPart, "http://schemas.xmlsoap.org/ws/2005/02/rm/TerminateSequence");
                signaturePart  = requirements.OutgoingSignatureParts;
                encryptionPart = requirements.OutgoingEncryptionParts;
                ProtectProtocolMessage(signaturePart, encryptionPart, "http://schemas.xmlsoap.org/ws/2005/02/rm/CreateSequenceResponse");
                ProtectProtocolMessage(signaturePart, encryptionPart, "http://schemas.xmlsoap.org/ws/2005/02/rm/SequenceAcknowledgement");
                ProtectProtocolMessage(signaturePart, encryptionPart, "http://schemas.xmlsoap.org/ws/2005/02/rm/LastMessage");
                ProtectProtocolMessage(signaturePart, encryptionPart, "http://schemas.xmlsoap.org/ws/2005/02/rm/TerminateSequence");
                return(requirements);
            }
            if (this.reliableMessagingVersion != System.ServiceModel.ReliableMessagingVersion.WSReliableMessaging11)
            {
                throw Fx.AssertAndThrow("Reliable messaging version not supported.");
            }
            ScopedMessagePartSpecification incomingSignatureParts  = requirements.IncomingSignatureParts;
            ScopedMessagePartSpecification incomingEncryptionParts = requirements.IncomingEncryptionParts;

            ProtectProtocolMessage(incomingSignatureParts, incomingEncryptionParts, "http://docs.oasis-open.org/ws-rx/wsrm/200702/AckRequested");
            ProtectProtocolMessage(incomingSignatureParts, incomingEncryptionParts, "http://docs.oasis-open.org/ws-rx/wsrm/200702/CloseSequence");
            ProtectProtocolMessage(incomingSignatureParts, incomingEncryptionParts, "http://docs.oasis-open.org/ws-rx/wsrm/200702/CloseSequenceResponse");
            ProtectProtocolMessage(incomingSignatureParts, incomingEncryptionParts, "http://docs.oasis-open.org/ws-rx/wsrm/200702/CreateSequence");
            ProtectProtocolMessage(incomingSignatureParts, incomingEncryptionParts, "http://docs.oasis-open.org/ws-rx/wsrm/200702/fault");
            ProtectProtocolMessage(incomingSignatureParts, incomingEncryptionParts, "http://docs.oasis-open.org/ws-rx/wsrm/200702/SequenceAcknowledgement");
            ProtectProtocolMessage(incomingSignatureParts, incomingEncryptionParts, "http://docs.oasis-open.org/ws-rx/wsrm/200702/TerminateSequence");
            ProtectProtocolMessage(incomingSignatureParts, incomingEncryptionParts, "http://docs.oasis-open.org/ws-rx/wsrm/200702/TerminateSequenceResponse");
            incomingSignatureParts  = requirements.OutgoingSignatureParts;
            incomingEncryptionParts = requirements.OutgoingEncryptionParts;
            ProtectProtocolMessage(incomingSignatureParts, incomingEncryptionParts, "http://docs.oasis-open.org/ws-rx/wsrm/200702/AckRequested");
            ProtectProtocolMessage(incomingSignatureParts, incomingEncryptionParts, "http://docs.oasis-open.org/ws-rx/wsrm/200702/CloseSequence");
            ProtectProtocolMessage(incomingSignatureParts, incomingEncryptionParts, "http://docs.oasis-open.org/ws-rx/wsrm/200702/CloseSequenceResponse");
            ProtectProtocolMessage(incomingSignatureParts, incomingEncryptionParts, "http://docs.oasis-open.org/ws-rx/wsrm/200702/CreateSequenceResponse");
            ProtectProtocolMessage(incomingSignatureParts, incomingEncryptionParts, "http://docs.oasis-open.org/ws-rx/wsrm/200702/fault");
            ProtectProtocolMessage(incomingSignatureParts, incomingEncryptionParts, "http://docs.oasis-open.org/ws-rx/wsrm/200702/SequenceAcknowledgement");
            ProtectProtocolMessage(incomingSignatureParts, incomingEncryptionParts, "http://docs.oasis-open.org/ws-rx/wsrm/200702/TerminateSequence");
            ProtectProtocolMessage(incomingSignatureParts, incomingEncryptionParts, "http://docs.oasis-open.org/ws-rx/wsrm/200702/TerminateSequenceResponse");
            return(requirements);
        }
예제 #29
0
        protected override void OnWriteDetailContents(XmlDictionaryWriter writer)
        {
            ReliableMessagingVersion reliableMessagingVersion = this.GetReliableMessagingVersion();

            WsrmUtilities.WriteIdentifier(writer, reliableMessagingVersion, this.SequenceID);

            if (reliableMessagingVersion == ReliableMessagingVersion.WSReliableMessaging11)
            {
                writer.WriteStartElement(WsrmFeb2005Strings.Prefix, DXD.Wsrm11Dictionary.MaxMessageNumber,
                                         WsrmIndex.GetNamespace(reliableMessagingVersion));
                writer.WriteValue(Int64.MaxValue);
                writer.WriteEndElement();
            }
        }
        private void CreateTerminateRequestor()
        {
            RequestReliableRequestor requestor = new RequestReliableRequestor();

            this.ConfigureRequestor(requestor);
            requestor.MessageAction = WsrmIndex.GetTerminateSequenceActionHeader(this.settings.MessageVersion.Addressing, this.settings.ReliableMessagingVersion);
            requestor.MessageBody   = new System.ServiceModel.Channels.TerminateSequence(this.settings.ReliableMessagingVersion, this.session.OutputID, this.connection.Last);
            lock (base.ThisLock)
            {
                base.ThrowIfClosed();
                this.terminateRequestor = requestor;
                this.session.CloseSession();
            }
        }