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();
        }
Exemplo n.º 2
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();
        }
Exemplo n.º 3
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();
            }
        }
Exemplo n.º 4
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);
        }
Exemplo n.º 5
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));
        }
        protected override void OnWriteHeaderContents(XmlDictionaryWriter writer, MessageVersion messageVersion)
        {
            WsrmFeb2005Dictionary dictionary          = XD.WsrmFeb2005Dictionary;
            XmlDictionaryString   dictionaryNamespace = this.DictionaryNamespace;

            writer.WriteStartElement(dictionary.Identifier, dictionaryNamespace);
            writer.WriteValue(this.sequenceID);
            writer.WriteEndElement();
        }
Exemplo n.º 7
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();
        }
Exemplo n.º 8
0
        public static XmlDictionaryReader GetReaderAtDetailContentsFeb2005(string detailName, string detailNamespace, XmlDictionaryReader headerReader)
        {
            XmlDictionaryReader reader;

            try
            {
                WsrmFeb2005Dictionary dictionary   = XD.WsrmFeb2005Dictionary;
                XmlDictionaryString   namespaceUri = dictionary.Namespace;
                XmlBuffer             buffer       = null;
                int sectionIndex = 0;
                int depth        = headerReader.Depth;
                headerReader.ReadFullStartElement(dictionary.SequenceFault, namespaceUri);
                while (headerReader.Depth > depth)
                {
                    if (((headerReader.NodeType == XmlNodeType.Element) && (headerReader.NamespaceURI == detailNamespace)) && (headerReader.LocalName == detailName))
                    {
                        if (buffer != null)
                        {
                            return(null);
                        }
                        buffer = new XmlBuffer(0x7fffffff);
                        try
                        {
                            sectionIndex = buffer.SectionCount;
                            buffer.OpenSection(headerReader.Quotas).WriteNode(headerReader, false);
                            continue;
                        }
                        finally
                        {
                            buffer.CloseSection();
                        }
                    }
                    if (headerReader.Depth == depth)
                    {
                        break;
                    }
                    headerReader.Read();
                }
                if (buffer == null)
                {
                    return(null);
                }
                buffer.Close();
                reader = buffer.GetReader(sectionIndex);
            }
            finally
            {
                headerReader.Close();
            }
            return(reader);
        }
Exemplo n.º 9
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));
        }
        protected override void OnWriteHeaderContents(XmlDictionaryWriter writer, MessageVersion messageVersion)
        {
            WsrmFeb2005Dictionary dictionary          = XD.WsrmFeb2005Dictionary;
            XmlDictionaryString   dictionaryNamespace = this.DictionaryNamespace;

            writer.WriteStartElement(dictionary.Identifier, dictionaryNamespace);
            writer.WriteValue(this.sequenceID);
            writer.WriteEndElement();
            writer.WriteStartElement(dictionary.MessageNumber, dictionaryNamespace);
            writer.WriteValue(this.sequenceNumber);
            writer.WriteEndElement();
            if ((base.ReliableMessagingVersion == ReliableMessagingVersion.WSReliableMessagingFebruary2005) && this.lastMessage)
            {
                writer.WriteStartElement(dictionary.LastMessage, dictionaryNamespace);
                writer.WriteEndElement();
            }
        }
Exemplo n.º 11
0
        protected override void OnWriteBodyContents(XmlDictionaryWriter writer)
        {
            WsrmFeb2005Dictionary dictionary   = XD.WsrmFeb2005Dictionary;
            XmlDictionaryString   namespaceUri = WsrmIndex.GetNamespace(this.reliableMessagingVersion);

            writer.WriteStartElement(dictionary.TerminateSequence, namespaceUri);
            writer.WriteStartElement(dictionary.Identifier, namespaceUri);
            writer.WriteValue(this.identifier);
            writer.WriteEndElement();
            if ((this.reliableMessagingVersion == ReliableMessagingVersion.WSReliableMessaging11) && (this.lastMsgNumber > 0L))
            {
                writer.WriteStartElement(DXD.Wsrm11Dictionary.LastMsgNumber, namespaceUri);
                writer.WriteValue(this.lastMsgNumber);
                writer.WriteEndElement();
            }
            writer.WriteEndElement();
        }
Exemplo n.º 12
0
        protected override void OnWriteHeaderContents(XmlDictionaryWriter writer, MessageVersion messageVersion)
        {
            WsrmFeb2005Dictionary dictionary          = XD.WsrmFeb2005Dictionary;
            XmlDictionaryString   dictionaryNamespace = this.DictionaryNamespace;

            WriteAckRanges(writer, base.ReliableMessagingVersion, this.sequenceID, this.ranges);
            if ((base.ReliableMessagingVersion == ReliableMessagingVersion.WSReliableMessaging11) && this.final)
            {
                writer.WriteStartElement(DXD.Wsrm11Dictionary.Final, dictionaryNamespace);
                writer.WriteEndElement();
            }
            if (this.bufferRemaining != -1)
            {
                writer.WriteStartElement("netrm", dictionary.BufferRemaining, XD.WsrmFeb2005Dictionary.NETNamespace);
                writer.WriteValue(this.bufferRemaining);
                writer.WriteEndElement();
            }
        }
Exemplo n.º 13
0
        protected override void OnWriteBodyContents(XmlDictionaryWriter writer)
        {
            WsrmFeb2005Dictionary wsrmFeb2005Dictionary = XD.WsrmFeb2005Dictionary;
            XmlDictionaryString   wsrmNs = WsrmIndex.GetNamespace(_reliableMessagingVersion);

            writer.WriteStartElement(wsrmFeb2005Dictionary.CreateSequence, wsrmNs);

            EndpointAddress localAddress = _binder.LocalAddress;

            localAddress.WriteTo(_addressingVersion, writer, wsrmFeb2005Dictionary.AcksTo, wsrmNs);

            if (_offerIdentifier != null)
            {
                writer.WriteStartElement(wsrmFeb2005Dictionary.Offer, wsrmNs);
                writer.WriteStartElement(wsrmFeb2005Dictionary.Identifier, wsrmNs);
                writer.WriteValue(_offerIdentifier);
                writer.WriteEndElement();

                if (_reliableMessagingVersion == ReliableMessagingVersion.WSReliableMessaging11)
                {
                    Wsrm11Dictionary wsrm11Dictionary = DXD.Wsrm11Dictionary;
                    localAddress.WriteTo(_addressingVersion, writer, wsrm11Dictionary.Endpoint, wsrmNs);

                    writer.WriteStartElement(wsrm11Dictionary.IncompleteSequenceBehavior, wsrmNs);
                    writer.WriteValue(
                        _ordered ? wsrm11Dictionary.DiscardFollowingFirstGap : wsrm11Dictionary.NoDiscard);
                    writer.WriteEndElement();
                }

                writer.WriteEndElement();
            }

            ISecureConversationSession securitySession = _binder.GetInnerSession() as ISecureConversationSession;

            if (securitySession != null)
            {
                securitySession.WriteSessionTokenIdentifier(writer);
            }

            writer.WriteEndElement();
        }
        public static CreateSequenceResponseInfo Create(AddressingVersion addressingVersion, ReliableMessagingVersion reliableMessagingVersion, XmlDictionaryReader reader)
        {
            CreateSequenceResponseInfo info         = new CreateSequenceResponseInfo();
            WsrmFeb2005Dictionary      dictionary   = XD.WsrmFeb2005Dictionary;
            XmlDictionaryString        namespaceUri = WsrmIndex.GetNamespace(reliableMessagingVersion);

            reader.ReadStartElement(dictionary.CreateSequenceResponse, namespaceUri);
            reader.ReadStartElement(dictionary.Identifier, namespaceUri);
            info.Identifier = reader.ReadContentAsUniqueId();
            reader.ReadEndElement();
            if (reader.IsStartElement(dictionary.Expires, namespaceUri))
            {
                reader.ReadElementContentAsTimeSpan();
            }
            if ((reliableMessagingVersion == ReliableMessagingVersion.WSReliableMessaging11) && reader.IsStartElement(DXD.Wsrm11Dictionary.IncompleteSequenceBehavior, namespaceUri))
            {
                string str2 = reader.ReadElementContentAsString();
                if (((str2 != "DiscardEntireSequence") && (str2 != "DiscardFollowingFirstGap")) && (str2 != "NoDiscard"))
                {
                    string message = System.ServiceModel.SR.GetString("CSResponseWithInvalidIncompleteSequenceBehavior");
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(message));
                }
            }
            if (reader.IsStartElement(dictionary.Accept, namespaceUri))
            {
                reader.ReadStartElement();
                info.AcceptAcksTo = EndpointAddress.ReadFrom(addressingVersion, reader, dictionary.AcksTo, namespaceUri);
                while (reader.IsStartElement())
                {
                    reader.Skip();
                }
                reader.ReadEndElement();
            }
            while (reader.IsStartElement())
            {
                reader.Skip();
            }
            reader.ReadEndElement();
            return(info);
        }
Exemplo n.º 15
0
        protected override void OnWriteBodyContents(XmlDictionaryWriter writer)
        {
            WsrmFeb2005Dictionary wsrmFeb2005Dictionary = XD.WsrmFeb2005Dictionary;
            XmlDictionaryString   wsrmNs = WsrmIndex.GetNamespace(_reliableMessagingVersion);

            writer.WriteStartElement(wsrmFeb2005Dictionary.TerminateSequence, wsrmNs);
            writer.WriteStartElement(wsrmFeb2005Dictionary.Identifier, wsrmNs);
            writer.WriteValue(_identifier);
            writer.WriteEndElement();

            if (_reliableMessagingVersion == ReliableMessagingVersion.WSReliableMessaging11)
            {
                if (_lastMsgNumber > 0)
                {
                    writer.WriteStartElement(DXD.Wsrm11Dictionary.LastMsgNumber, wsrmNs);
                    writer.WriteValue(_lastMsgNumber);
                    writer.WriteEndElement();
                }
            }

            writer.WriteEndElement();
        }
Exemplo n.º 16
0
        protected override ActionHeader GetActionHeader(string element)
        {
            WsrmFeb2005Dictionary dictionary = XD.WsrmFeb2005Dictionary;

            if (element == "AckRequested")
            {
                if (this.ackRequestedActionHeader == null)
                {
                    this.ackRequestedActionHeader = ActionHeader.Create(dictionary.AckRequestedAction, this.addressingVersion);
                }
                return(this.ackRequestedActionHeader);
            }
            if (element == "CreateSequence")
            {
                if (this.createSequenceActionHeader == null)
                {
                    this.createSequenceActionHeader = ActionHeader.Create(dictionary.CreateSequenceAction, this.addressingVersion);
                }
                return(this.createSequenceActionHeader);
            }
            if (element == "SequenceAcknowledgement")
            {
                if (this.sequenceAcknowledgementActionHeader == null)
                {
                    this.sequenceAcknowledgementActionHeader = ActionHeader.Create(dictionary.SequenceAcknowledgementAction, this.addressingVersion);
                }
                return(this.sequenceAcknowledgementActionHeader);
            }
            if (!(element == "TerminateSequence"))
            {
                throw Fx.AssertAndThrow("Element not supported.");
            }
            if (this.terminateSequenceActionHeader == null)
            {
                this.terminateSequenceActionHeader = ActionHeader.Create(dictionary.TerminateSequenceAction, this.addressingVersion);
            }
            return(this.terminateSequenceActionHeader);
        }
Exemplo n.º 17
0
        public static TerminateSequenceInfo Create(ReliableMessagingVersion reliableMessagingVersion, XmlDictionaryReader reader)
        {
            TerminateSequenceInfo info         = new TerminateSequenceInfo();
            WsrmFeb2005Dictionary dictionary   = XD.WsrmFeb2005Dictionary;
            XmlDictionaryString   namespaceUri = WsrmIndex.GetNamespace(reliableMessagingVersion);

            reader.ReadStartElement(dictionary.TerminateSequence, namespaceUri);
            reader.ReadStartElement(dictionary.Identifier, namespaceUri);
            info.Identifier = reader.ReadContentAsUniqueId();
            reader.ReadEndElement();
            if ((reliableMessagingVersion == ReliableMessagingVersion.WSReliableMessaging11) && reader.IsStartElement(DXD.Wsrm11Dictionary.LastMsgNumber, namespaceUri))
            {
                reader.ReadStartElement();
                info.LastMsgNumber = WsrmUtilities.ReadSequenceNumber(reader, false);
                reader.ReadEndElement();
            }
            while (reader.IsStartElement())
            {
                reader.Skip();
            }
            reader.ReadEndElement();
            return(info);
        }
Exemplo n.º 18
0
        public static TerminateSequenceInfo Create(ReliableMessagingVersion reliableMessagingVersion,
                                                   XmlDictionaryReader reader)
        {
            if (reader == null)
            {
                Fx.Assert("Argument reader cannot be null.");
            }

            TerminateSequenceInfo terminateSequenceInfo = new TerminateSequenceInfo();
            WsrmFeb2005Dictionary wsrmFeb2005Dictionary = XD.WsrmFeb2005Dictionary;
            XmlDictionaryString   wsrmNs = WsrmIndex.GetNamespace(reliableMessagingVersion);

            reader.ReadStartElement(wsrmFeb2005Dictionary.TerminateSequence, wsrmNs);

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

            if (reliableMessagingVersion == ReliableMessagingVersion.WSReliableMessaging11)
            {
                if (reader.IsStartElement(DXD.Wsrm11Dictionary.LastMsgNumber, wsrmNs))
                {
                    reader.ReadStartElement();
                    terminateSequenceInfo.LastMsgNumber = WsrmUtilities.ReadSequenceNumber(reader, false);
                    reader.ReadEndElement();
                }
            }

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

            reader.ReadEndElement();

            return(terminateSequenceInfo);
        }
Exemplo n.º 19
0
        public static string GetSubcode(XmlDictionaryReader headerReader,
                                        ReliableMessagingVersion reliableMessagingVersion)
        {
            string subCode = null;

            try
            {
                WsrmFeb2005Dictionary wsrmFeb2005Dictionary = XD.WsrmFeb2005Dictionary;
                XmlDictionaryString   wsrmNs = WsrmIndex.GetNamespace(reliableMessagingVersion);
                string ns;

                headerReader.ReadStartElement(wsrmFeb2005Dictionary.SequenceFault, wsrmNs);
                headerReader.ReadStartElement(wsrmFeb2005Dictionary.FaultCode, wsrmNs);
                XmlUtil.ReadContentAsQName(headerReader, out subCode, out ns);

                if (ns != WsrmIndex.GetNamespaceString(reliableMessagingVersion))
                {
                    subCode = null;
                }

                headerReader.ReadEndElement();

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

                headerReader.ReadEndElement();
            }
            finally
            {
                headerReader.Close();
            }

            return(subCode);
        }
Exemplo n.º 20
0
        protected override void OnWriteBodyContents(XmlDictionaryWriter writer)
        {
            WsrmFeb2005Dictionary wsrmFeb2005Dictionary = XD.WsrmFeb2005Dictionary;
            XmlDictionaryString   wsrmNs = WsrmIndex.GetNamespace(_reliableMessagingVersion);

            writer.WriteStartElement(wsrmFeb2005Dictionary.CreateSequenceResponse, wsrmNs);

            writer.WriteStartElement(wsrmFeb2005Dictionary.Identifier, wsrmNs);
            writer.WriteValue(Identifier);
            writer.WriteEndElement();

            if (Expires.HasValue)
            {
                writer.WriteStartElement(wsrmFeb2005Dictionary.Expires, wsrmNs);
                writer.WriteValue(Expires.Value);
                writer.WriteEndElement();
            }

            if (_reliableMessagingVersion == ReliableMessagingVersion.WSReliableMessaging11)
            {
                Wsrm11Dictionary wsrm11Dictionary = DXD.Wsrm11Dictionary;
                writer.WriteStartElement(wsrm11Dictionary.IncompleteSequenceBehavior, wsrmNs);
                writer.WriteValue(
                    Ordered ? wsrm11Dictionary.DiscardFollowingFirstGap : wsrm11Dictionary.NoDiscard);
                writer.WriteEndElement();
            }

            if (AcceptAcksTo != null)
            {
                writer.WriteStartElement(wsrmFeb2005Dictionary.Accept, wsrmNs);
                AcceptAcksTo.WriteTo(_addressingVersion, writer, wsrmFeb2005Dictionary.AcksTo, wsrmNs);
                writer.WriteEndElement();
            }

            writer.WriteEndElement();
        }
Exemplo n.º 21
0
        public static XmlDictionaryReader GetReaderAtDetailContentsFeb2005(string detailName, string detailNamespace,
                                                                           XmlDictionaryReader headerReader)
        {
            try
            {
                WsrmFeb2005Dictionary wsrmFeb2005Dictionary = XD.WsrmFeb2005Dictionary;
                XmlDictionaryString   wsrmNs = wsrmFeb2005Dictionary.Namespace;
                XmlBuffer             buffer = null;
                int index = 0;
                int depth = headerReader.Depth;
                headerReader.ReadFullStartElement(wsrmFeb2005Dictionary.SequenceFault, wsrmNs);

                while (headerReader.Depth > depth)
                {
                    if ((headerReader.NodeType == XmlNodeType.Element) &&
                        (headerReader.NamespaceURI == detailNamespace) &&
                        (headerReader.LocalName == detailName))
                    {
                        if (buffer != null)
                        {
                            return(null);
                        }

                        buffer = new XmlBuffer(int.MaxValue);

                        try
                        {
                            index = buffer.SectionCount;
                            XmlDictionaryWriter writer = buffer.OpenSection(headerReader.Quotas);
                            // WriteNode moves the reader to the next sibling.
                            writer.WriteNode(headerReader, false);
                        }
                        finally
                        {
                            buffer.CloseSection();
                        }
                    }
                    else
                    {
                        if (headerReader.Depth == depth)
                        {
                            break;
                        }

                        headerReader.Read();
                    }
                }

                // Ensure at least one detail is found;
                if (buffer == null)
                {
                    return(null);
                }

                // Close causes a state change.  It moves the buffer from Created to Reading.
                buffer.Close();
                XmlDictionaryReader detailReader = buffer.GetReader(index);
                return(detailReader);
            }
            finally
            {
                headerReader.Close();
            }
        }
Exemplo n.º 22
0
        public static CreateSequenceInfo Create(MessageVersion messageVersion,
                                                ReliableMessagingVersion reliableMessagingVersion, ISecureConversationSession securitySession,
                                                XmlDictionaryReader reader)
        {
            if (reader == null)
            {
                Fx.Assert("Argument reader cannot be null.");
            }

            try
            {
                CreateSequenceInfo    info = new CreateSequenceInfo();
                WsrmFeb2005Dictionary wsrmFeb2005Dictionary = XD.WsrmFeb2005Dictionary;
                XmlDictionaryString   wsrmNs = WsrmIndex.GetNamespace(reliableMessagingVersion);
                reader.ReadStartElement(wsrmFeb2005Dictionary.CreateSequence, wsrmNs);

                info.AcksTo = EndpointAddress.ReadFrom(messageVersion.Addressing, reader, wsrmFeb2005Dictionary.AcksTo, wsrmNs);

                if (reader.IsStartElement(wsrmFeb2005Dictionary.Expires, wsrmNs))
                {
                    info.Expires = reader.ReadElementContentAsTimeSpan();
                }

                if (reader.IsStartElement(wsrmFeb2005Dictionary.Offer, wsrmNs))
                {
                    reader.ReadStartElement();

                    reader.ReadStartElement(wsrmFeb2005Dictionary.Identifier, wsrmNs);
                    info.OfferIdentifier = reader.ReadContentAsUniqueId();
                    reader.ReadEndElement();

                    bool             wsrm11           = reliableMessagingVersion == ReliableMessagingVersion.WSReliableMessaging11;
                    Wsrm11Dictionary wsrm11Dictionary = wsrm11 ? DXD.Wsrm11Dictionary : null;

                    if (wsrm11)
                    {
                        EndpointAddress endpoint = EndpointAddress.ReadFrom(messageVersion.Addressing, reader,
                                                                            wsrm11Dictionary.Endpoint, wsrmNs);

                        if (endpoint.Uri != info.AcksTo.Uri)
                        {
                            string  reason     = SR.GetString(SR.CSRefusedAcksToMustEqualEndpoint);
                            Message faultReply = WsrmUtilities.CreateCSRefusedProtocolFault(messageVersion, reliableMessagingVersion, reason);
                            throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(WsrmMessageInfo.CreateInternalFaultException(faultReply, reason, new ProtocolException(reason)));
                        }
                    }

                    if (reader.IsStartElement(wsrmFeb2005Dictionary.Expires, wsrmNs))
                    {
                        info.OfferExpires = reader.ReadElementContentAsTimeSpan();
                    }

                    if (wsrm11)
                    {
                        if (reader.IsStartElement(wsrm11Dictionary.IncompleteSequenceBehavior, wsrmNs))
                        {
                            string incompleteSequenceBehavior = reader.ReadElementContentAsString();

                            if ((incompleteSequenceBehavior != Wsrm11Strings.DiscardEntireSequence) &&
                                (incompleteSequenceBehavior != Wsrm11Strings.DiscardFollowingFirstGap) &&
                                (incompleteSequenceBehavior != Wsrm11Strings.NoDiscard))
                            {
                                string  reason     = SR.GetString(SR.CSRefusedInvalidIncompleteSequenceBehavior);
                                Message faultReply = WsrmUtilities.CreateCSRefusedProtocolFault(messageVersion, reliableMessagingVersion, reason);
                                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
                                          WsrmMessageInfo.CreateInternalFaultException(faultReply, reason,
                                                                                       new ProtocolException(reason)));
                            }

                            // Otherwise ignore the value.
                        }
                    }

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

                    reader.ReadEndElement();
                }

                // Check for security only if we expect a soap security session.
                if (securitySession != null)
                {
                    bool hasValidToken = false;

                    // Since the security element is amongst the extensible elements (i.e. there is no
                    // gaurantee of ordering or placement), a loop is required to attempt to parse the
                    // security element.
                    while (reader.IsStartElement())
                    {
                        if (securitySession.TryReadSessionTokenIdentifier(reader))
                        {
                            hasValidToken = true;
                            break;
                        }

                        reader.Skip();
                    }

                    if (!hasValidToken)
                    {
                        string  reason     = SR.GetString(SR.CSRefusedRequiredSecurityElementMissing);
                        Message faultReply = WsrmUtilities.CreateCSRefusedProtocolFault(messageVersion, reliableMessagingVersion, reason);
                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(WsrmMessageInfo.CreateInternalFaultException(faultReply, reason, new ProtocolException(reason)));
                    }
                }

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

                reader.ReadEndElement();

                if (reader.IsStartElement())
                {
                    string  reason     = SR.GetString(SR.CSRefusedUnexpectedElementAtEndOfCSMessage);
                    Message faultReply = WsrmUtilities.CreateCSRefusedProtocolFault(messageVersion, reliableMessagingVersion, reason);
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(WsrmMessageInfo.CreateInternalFaultException(faultReply, reason, new ProtocolException(reason)));
                }

                return(info);
            }
            catch (XmlException e)
            {
                string  reason     = SR.GetString(SR.CouldNotParseWithAction, WsrmIndex.GetCreateSequenceActionString(reliableMessagingVersion));
                Message faultReply = WsrmUtilities.CreateCSRefusedProtocolFault(messageVersion, reliableMessagingVersion, reason);
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(WsrmMessageInfo.CreateInternalFaultException(faultReply, reason, new ProtocolException(reason, e)));
            }
        }
Exemplo n.º 23
0
        public static CreateSequenceInfo Create(MessageVersion messageVersion, ReliableMessagingVersion reliableMessagingVersion, ISecureConversationSession securitySession, XmlDictionaryReader reader)
        {
            CreateSequenceInfo info2;

            try
            {
                CreateSequenceInfo    info         = new CreateSequenceInfo();
                WsrmFeb2005Dictionary dictionary   = XD.WsrmFeb2005Dictionary;
                XmlDictionaryString   namespaceUri = WsrmIndex.GetNamespace(reliableMessagingVersion);
                reader.ReadStartElement(dictionary.CreateSequence, namespaceUri);
                info.AcksTo = EndpointAddress.ReadFrom(messageVersion.Addressing, reader, dictionary.AcksTo, namespaceUri);
                if (reader.IsStartElement(dictionary.Expires, namespaceUri))
                {
                    info.Expires = new TimeSpan?(reader.ReadElementContentAsTimeSpan());
                }
                if (!reader.IsStartElement(dictionary.Offer, namespaceUri))
                {
                    goto Label_01B7;
                }
                reader.ReadStartElement();
                reader.ReadStartElement(dictionary.Identifier, namespaceUri);
                info.OfferIdentifier = reader.ReadContentAsUniqueId();
                reader.ReadEndElement();
                bool             flag        = reliableMessagingVersion == ReliableMessagingVersion.WSReliableMessaging11;
                Wsrm11Dictionary dictionary2 = flag ? DXD.Wsrm11Dictionary : null;
                if (flag && (EndpointAddress.ReadFrom(messageVersion.Addressing, reader, dictionary2.Endpoint, namespaceUri).Uri != info.AcksTo.Uri))
                {
                    string  str2    = System.ServiceModel.SR.GetString("CSRefusedAcksToMustEqualEndpoint");
                    Message message = WsrmUtilities.CreateCSRefusedProtocolFault(messageVersion, reliableMessagingVersion, str2);
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(WsrmMessageInfo.CreateInternalFaultException(message, str2, new ProtocolException(str2)));
                }
                if (reader.IsStartElement(dictionary.Expires, namespaceUri))
                {
                    info.OfferExpires = new TimeSpan?(reader.ReadElementContentAsTimeSpan());
                }
                if (!flag || !reader.IsStartElement(dictionary2.IncompleteSequenceBehavior, namespaceUri))
                {
                    goto Label_01A9;
                }
                string str3 = reader.ReadElementContentAsString();
                if ((!(str3 != "DiscardEntireSequence") || !(str3 != "DiscardFollowingFirstGap")) || !(str3 != "NoDiscard"))
                {
                    goto Label_01A9;
                }
                string  reason     = System.ServiceModel.SR.GetString("CSRefusedInvalidIncompleteSequenceBehavior");
                Message faultReply = WsrmUtilities.CreateCSRefusedProtocolFault(messageVersion, reliableMessagingVersion, reason);
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(WsrmMessageInfo.CreateInternalFaultException(faultReply, reason, new ProtocolException(reason)));
Label_01A3:
                reader.Skip();
Label_01A9:
                if (reader.IsStartElement())
                {
                    goto Label_01A3;
                }
                reader.ReadEndElement();
Label_01B7:
                if (securitySession == null)
                {
                    goto Label_0217;
                }
                bool flag2 = false;
                while (reader.IsStartElement())
                {
                    if (securitySession.TryReadSessionTokenIdentifier(reader))
                    {
                        flag2 = true;
                        break;
                    }
                    reader.Skip();
                }
                if (flag2)
                {
                    goto Label_0217;
                }
                string  str5     = System.ServiceModel.SR.GetString("CSRefusedRequiredSecurityElementMissing");
                Message message3 = WsrmUtilities.CreateCSRefusedProtocolFault(messageVersion, reliableMessagingVersion, str5);
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(WsrmMessageInfo.CreateInternalFaultException(message3, str5, new ProtocolException(str5)));
Label_0211:
                reader.Skip();
Label_0217:
                if (reader.IsStartElement())
                {
                    goto Label_0211;
                }
                reader.ReadEndElement();
                if (reader.IsStartElement())
                {
                    string  str6     = System.ServiceModel.SR.GetString("CSRefusedUnexpectedElementAtEndOfCSMessage");
                    Message message4 = WsrmUtilities.CreateCSRefusedProtocolFault(messageVersion, reliableMessagingVersion, str6);
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(WsrmMessageInfo.CreateInternalFaultException(message4, str6, new ProtocolException(str6)));
                }
                info2 = info;
            }
            catch (XmlException exception)
            {
                string  str7     = System.ServiceModel.SR.GetString("CouldNotParseWithAction", new object[] { WsrmIndex.GetCreateSequenceActionString(reliableMessagingVersion) });
                Message message5 = WsrmUtilities.CreateCSRefusedProtocolFault(messageVersion, reliableMessagingVersion, str7);
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(WsrmMessageInfo.CreateInternalFaultException(message5, str7, new ProtocolException(str7, exception)));
            }
            return(info2);
        }
Exemplo n.º 24
0
        public static CreateSequenceResponseInfo Create(AddressingVersion addressingVersion,
                                                        ReliableMessagingVersion reliableMessagingVersion, XmlDictionaryReader reader)
        {
            if (reader == null)
            {
                Fx.Assert("Argument reader cannot be null.");
            }

            CreateSequenceResponseInfo createSequenceResponse = new CreateSequenceResponseInfo();
            WsrmFeb2005Dictionary      wsrmFeb2005Dictionary  = XD.WsrmFeb2005Dictionary;
            XmlDictionaryString        wsrmNs = WsrmIndex.GetNamespace(reliableMessagingVersion);

            reader.ReadStartElement(wsrmFeb2005Dictionary.CreateSequenceResponse, wsrmNs);

            reader.ReadStartElement(wsrmFeb2005Dictionary.Identifier, wsrmNs);
            createSequenceResponse.Identifier = reader.ReadContentAsUniqueId();
            reader.ReadEndElement();

            if (reader.IsStartElement(wsrmFeb2005Dictionary.Expires, wsrmNs))
            {
                reader.ReadElementContentAsTimeSpan();
            }

            if (reliableMessagingVersion == ReliableMessagingVersion.WSReliableMessaging11)
            {
                if (reader.IsStartElement(DXD.Wsrm11Dictionary.IncompleteSequenceBehavior, wsrmNs))
                {
                    string incompleteSequenceBehavior = reader.ReadElementContentAsString();

                    if ((incompleteSequenceBehavior != Wsrm11Strings.DiscardEntireSequence) &&
                        (incompleteSequenceBehavior != Wsrm11Strings.DiscardFollowingFirstGap) &&
                        (incompleteSequenceBehavior != Wsrm11Strings.NoDiscard))
                    {
                        string reason = SR.CSResponseWithInvalidIncompleteSequenceBehavior;
                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(reason));
                    }

                    // Otherwise ignore the value.
                }
            }

            if (reader.IsStartElement(wsrmFeb2005Dictionary.Accept, wsrmNs))
            {
                reader.ReadStartElement();
                createSequenceResponse.AcceptAcksTo = EndpointAddress.ReadFrom(addressingVersion, reader,
                                                                               wsrmFeb2005Dictionary.AcksTo, wsrmNs);
                while (reader.IsStartElement())
                {
                    reader.Skip();
                }
                reader.ReadEndElement();
            }

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

            reader.ReadEndElement();

            return(createSequenceResponse);
        }
Exemplo n.º 25
0
        internal static void ReadAck(ReliableMessagingVersion reliableMessagingVersion, XmlDictionaryReader reader, out UniqueId sequenceId, out SequenceRangeCollection rangeCollection, out bool final)
        {
            WsrmFeb2005Dictionary dictionary   = XD.WsrmFeb2005Dictionary;
            XmlDictionaryString   namespaceUri = WsrmIndex.GetNamespace(reliableMessagingVersion);

            reader.ReadStartElement(dictionary.SequenceAcknowledgement, namespaceUri);
            reader.ReadStartElement(dictionary.Identifier, namespaceUri);
            sequenceId = reader.ReadContentAsUniqueId();
            reader.ReadEndElement();
            bool allowZero = reliableMessagingVersion == ReliableMessagingVersion.WSReliableMessagingFebruary2005;

            rangeCollection = SequenceRangeCollection.Empty;
            while (reader.IsStartElement(dictionary.AcknowledgementRange, namespaceUri))
            {
                reader.MoveToAttribute("Lower");
                long lower = WsrmUtilities.ReadSequenceNumber(reader, allowZero);
                reader.MoveToAttribute("Upper");
                long upper = WsrmUtilities.ReadSequenceNumber(reader, allowZero);
                if ((((lower < 0L) || (lower > upper)) || (((reliableMessagingVersion == ReliableMessagingVersion.WSReliableMessagingFebruary2005) && (lower == 0L)) && (upper > 0L))) || ((reliableMessagingVersion == ReliableMessagingVersion.WSReliableMessaging11) && (lower == 0L)))
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(System.ServiceModel.SR.GetString("InvalidSequenceRange", new object[] { lower, upper })));
                }
                rangeCollection = rangeCollection.MergeWith(new SequenceRange(lower, upper));
                reader.MoveToElement();
                WsrmUtilities.ReadEmptyElement(reader);
            }
            bool flag2 = rangeCollection.Count > 0;

            final = false;
            if (reliableMessagingVersion == ReliableMessagingVersion.WSReliableMessaging11)
            {
                Wsrm11Dictionary dictionary2 = DXD.Wsrm11Dictionary;
                if (reader.IsStartElement(dictionary2.None, namespaceUri))
                {
                    if (flag2)
                    {
                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(System.ServiceModel.SR.GetString("UnexpectedXmlChildNode", new object[] { reader.Name, reader.NodeType, dictionary.SequenceAcknowledgement })));
                    }
                    WsrmUtilities.ReadEmptyElement(reader);
                    flag2 = true;
                }
                if (reader.IsStartElement(dictionary2.Final, namespaceUri))
                {
                    if (!flag2)
                    {
                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(System.ServiceModel.SR.GetString("UnexpectedXmlChildNode", new object[] { reader.Name, reader.NodeType, dictionary.SequenceAcknowledgement })));
                    }
                    WsrmUtilities.ReadEmptyElement(reader);
                    final = true;
                }
            }
            bool flag4 = false;

            while (reader.IsStartElement(dictionary.Nack, namespaceUri))
            {
                if (flag2)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(System.ServiceModel.SR.GetString("UnexpectedXmlChildNode", new object[] { reader.Name, reader.NodeType, "Body" })));
                }
                reader.ReadStartElement();
                WsrmUtilities.ReadSequenceNumber(reader, true);
                reader.ReadEndElement();
                flag4 = true;
            }
            if (!flag2 && !flag4)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(System.ServiceModel.SR.GetString("UnexpectedXmlChildNode", new object[] { reader.Name, reader.NodeType, "Body" })));
            }
        }