public static CloseSequenceResponseInfo Create(XmlDictionaryReader reader) { if (reader == null) { Fx.Assert("Argument reader cannot be null."); } CloseSequenceResponseInfo closeSequenceResponseInfo = new CloseSequenceResponseInfo(); XmlDictionaryString wsrmNs = WsrmIndex.GetNamespace(ReliableMessagingVersion.WSReliableMessaging11); reader.ReadStartElement(DXD.Wsrm11Dictionary.CloseSequenceResponse, wsrmNs); reader.ReadStartElement(XD.WsrmFeb2005Dictionary.Identifier, wsrmNs); closeSequenceResponseInfo.Identifier = reader.ReadContentAsUniqueId(); reader.ReadEndElement(); while (reader.IsStartElement()) { reader.Skip(); } reader.ReadEndElement(); return closeSequenceResponseInfo; }
public static CloseSequenceResponseInfo Create(XmlDictionaryReader reader) { CloseSequenceResponseInfo info = new CloseSequenceResponseInfo(); XmlDictionaryString namespaceUri = WsrmIndex.GetNamespace(ReliableMessagingVersion.WSReliableMessaging11); reader.ReadStartElement(DXD.Wsrm11Dictionary.CloseSequenceResponse, namespaceUri); reader.ReadStartElement(XD.WsrmFeb2005Dictionary.Identifier, namespaceUri); info.Identifier = reader.ReadContentAsUniqueId(); reader.ReadEndElement(); while (reader.IsStartElement()) { reader.Skip(); } reader.ReadEndElement(); return info; }
public static WsrmAckRequestedInfo 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(); if ((reliableMessagingVersion == ReliableMessagingVersion.WSReliableMessagingFebruary2005) && reader.IsStartElement(dictionary.MessageNumber, namespaceUri)) { reader.ReadStartElement(); WsrmUtilities.ReadSequenceNumber(reader, true); reader.ReadEndElement(); } while (reader.IsStartElement()) { reader.Skip(); } reader.ReadEndElement(); return new WsrmAckRequestedInfo(sequenceID, header); }
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; }
public static CloseSequenceInfo Create(XmlDictionaryReader reader) { CloseSequenceInfo info = new CloseSequenceInfo(); XmlDictionaryString namespaceUri = WsrmIndex.GetNamespace(ReliableMessagingVersion.WSReliableMessaging11); Wsrm11Dictionary dictionary = DXD.Wsrm11Dictionary; reader.ReadStartElement(dictionary.CloseSequence, namespaceUri); reader.ReadStartElement(XD.WsrmFeb2005Dictionary.Identifier, namespaceUri); info.Identifier = reader.ReadContentAsUniqueId(); reader.ReadEndElement(); if (reader.IsStartElement(dictionary.LastMsgNumber, namespaceUri)) { reader.ReadStartElement(); info.LastMsgNumber = WsrmUtilities.ReadSequenceNumber(reader, false); reader.ReadEndElement(); } while (reader.IsStartElement()) { reader.Skip(); } reader.ReadEndElement(); return info; }
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; }
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.GetString(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; }
static public UniqueId ReadElementStringAsUniqueId(XmlDictionaryReader reader) { if (reader.IsStartElement() && reader.IsEmptyElement) { reader.Read(); return new UniqueId(string.Empty); } reader.ReadStartElement(); UniqueId id = reader.ReadContentAsUniqueId(); reader.ReadEndElement(); return id; }
private static UniqueId GetAttributeAsUniqueId(XmlDictionaryReader reader, string name, string ns) { if (!reader.MoveToAttribute(name, ns)) { return null; } UniqueId id = reader.ReadContentAsUniqueId(); reader.MoveToElement(); return id; }
// February 2005 - Reads Identifier, AcknowledgementRange, Nack // 1.1 - Reads Identifier, AcknowledgementRange, None, Final, Nack internal static void ReadAck(ReliableMessagingVersion reliableMessagingVersion, XmlDictionaryReader reader, out UniqueId sequenceId, out SequenceRangeCollection rangeCollection, out bool final) { WsrmFeb2005Dictionary wsrmFeb2005Dictionary = XD.WsrmFeb2005Dictionary; XmlDictionaryString wsrmNs = WsrmIndex.GetNamespace(reliableMessagingVersion); reader.ReadStartElement(wsrmFeb2005Dictionary.SequenceAcknowledgement, wsrmNs); reader.ReadStartElement(wsrmFeb2005Dictionary.Identifier, wsrmNs); sequenceId = reader.ReadContentAsUniqueId(); reader.ReadEndElement(); bool allowZero = reliableMessagingVersion == ReliableMessagingVersion.WSReliableMessagingFebruary2005; rangeCollection = SequenceRangeCollection.Empty; while (reader.IsStartElement(wsrmFeb2005Dictionary.AcknowledgementRange, wsrmNs)) { reader.MoveToAttribute(WsrmFeb2005Strings.Lower); Int64 lower = WsrmUtilities.ReadSequenceNumber(reader, allowZero); reader.MoveToAttribute(WsrmFeb2005Strings.Upper); Int64 upper = WsrmUtilities.ReadSequenceNumber(reader, allowZero); if (lower < 0 || lower > upper || ((reliableMessagingVersion == ReliableMessagingVersion.WSReliableMessagingFebruary2005) && (lower == 0 && upper > 0)) || ((reliableMessagingVersion == ReliableMessagingVersion.WSReliableMessaging11) && (lower == 0))) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError( new XmlException(SR.GetString(SR.InvalidSequenceRange, lower, upper))); } rangeCollection = rangeCollection.MergeWith(new SequenceRange(lower, upper)); reader.MoveToElement(); WsrmUtilities.ReadEmptyElement(reader); } bool validAck = rangeCollection.Count > 0; final = false; bool wsrm11 = reliableMessagingVersion == ReliableMessagingVersion.WSReliableMessaging11; if (wsrm11) { Wsrm11Dictionary wsrm11Dictionary = DXD.Wsrm11Dictionary; if (reader.IsStartElement(wsrm11Dictionary.None, wsrmNs)) { if (validAck) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException( SR.GetString(SR.UnexpectedXmlChildNode, reader.Name, reader.NodeType, wsrmFeb2005Dictionary.SequenceAcknowledgement))); } WsrmUtilities.ReadEmptyElement(reader); validAck = true; } if (reader.IsStartElement(wsrm11Dictionary.Final, wsrmNs)) { if (!validAck) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException( SR.GetString(SR.UnexpectedXmlChildNode, reader.Name, reader.NodeType, wsrmFeb2005Dictionary.SequenceAcknowledgement))); } WsrmUtilities.ReadEmptyElement(reader); final = true; } } bool foundNack = false; while (reader.IsStartElement(wsrmFeb2005Dictionary.Nack, wsrmNs)) { if (validAck) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException( SR.GetString(SR.UnexpectedXmlChildNode, reader.Name, reader.NodeType, MessageStrings.Body))); } reader.ReadStartElement(); WsrmUtilities.ReadSequenceNumber(reader, true); reader.ReadEndElement(); foundNack = true; } if (!validAck && !foundNack) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException( SR.GetString(SR.UnexpectedXmlChildNode, reader.Name, reader.NodeType, MessageStrings.Body))); } }
protected override void WriteTextNode(XmlDictionaryReader reader, bool attribute) { Type valueType = reader.ValueType; if (valueType == typeof(string)) { XmlDictionaryString str; if (reader.TryGetValueAsDictionaryString(out str)) { this.WriteString(str); } else if (reader.CanReadValueChunk) { int num; if (this.chars == null) { this.chars = new char[0x100]; } while ((num = reader.ReadValueChunk(this.chars, 0, this.chars.Length)) > 0) { this.WriteChars(this.chars, 0, num); } } else { this.WriteString(reader.Value); } if (!attribute) { reader.Read(); } } else if (valueType == typeof(byte[])) { if (reader.CanReadBinaryContent) { int num2; if (this.bytes == null) { this.bytes = new byte[0x180]; } while ((num2 = reader.ReadValueAsBase64(this.bytes, 0, this.bytes.Length)) > 0) { this.WriteBase64(this.bytes, 0, num2); } } else { this.WriteString(reader.Value); } if (!attribute) { reader.Read(); } } else if (valueType == typeof(int)) { this.WriteValue(reader.ReadContentAsInt()); } else if (valueType == typeof(long)) { this.WriteValue(reader.ReadContentAsLong()); } else if (valueType == typeof(bool)) { this.WriteValue(reader.ReadContentAsBoolean()); } else if (valueType == typeof(double)) { this.WriteValue(reader.ReadContentAsDouble()); } else if (valueType == typeof(DateTime)) { this.WriteValue(reader.ReadContentAsDateTime()); } else if (valueType == typeof(float)) { this.WriteValue(reader.ReadContentAsFloat()); } else if (valueType == typeof(decimal)) { this.WriteValue(reader.ReadContentAsDecimal()); } else if (valueType == typeof(UniqueId)) { this.WriteValue(reader.ReadContentAsUniqueId()); } else if (valueType == typeof(Guid)) { this.WriteValue(reader.ReadContentAsGuid()); } else if (valueType == typeof(TimeSpan)) { this.WriteValue(reader.ReadContentAsTimeSpan()); } else { this.WriteValue(reader.ReadContentAsObject()); } }
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; }
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))); } }
protected override void WriteTextNode(XmlDictionaryReader reader, bool attribute) { Type type = reader.ValueType; if (type == typeof(string)) { XmlDictionaryString value; if (reader.TryGetValueAsDictionaryString(out value)) { WriteString(value); } else { if (reader.CanReadValueChunk) { if (_chars == null) { _chars = new char[256]; } int count; while ((count = reader.ReadValueChunk(_chars, 0, _chars.Length)) > 0) { this.WriteChars(_chars, 0, count); } } else { WriteString(reader.Value); } } if (!attribute) { reader.Read(); } } else if (type == typeof(byte[])) { if (reader.CanReadBinaryContent) { // Its best to read in buffers that are a multiple of 3 so we don't break base64 boundaries when converting text if (_bytes == null) { _bytes = new byte[384]; } int count; while ((count = reader.ReadValueAsBase64(_bytes, 0, _bytes.Length)) > 0) { this.WriteBase64(_bytes, 0, count); } } else { WriteString(reader.Value); } if (!attribute) { reader.Read(); } } else if (type == typeof(int)) WriteValue(reader.ReadContentAsInt()); else if (type == typeof(long)) WriteValue(reader.ReadContentAsLong()); else if (type == typeof(bool)) WriteValue(reader.ReadContentAsBoolean()); else if (type == typeof(double)) WriteValue(reader.ReadContentAsDouble()); else if (type == typeof(DateTime)) WriteValue(reader.ReadContentAsDateTimeOffset().DateTime); else if (type == typeof(float)) WriteValue(reader.ReadContentAsFloat()); else if (type == typeof(decimal)) WriteValue(reader.ReadContentAsDecimal()); else if (type == typeof(UniqueId)) WriteValue(reader.ReadContentAsUniqueId()); else if (type == typeof(Guid)) WriteValue(reader.ReadContentAsGuid()); else if (type == typeof(TimeSpan)) WriteValue(reader.ReadContentAsTimeSpan()); else WriteValue(reader.ReadContentAsObject()); }
public static WsrmSequencedMessageInfo ReadHeader(ReliableMessagingVersion reliableMessagingVersion, XmlDictionaryReader reader, MessageHeaderInfo header) { WsrmFeb2005Dictionary wsrmFeb2005Dictionary = XD.WsrmFeb2005Dictionary; XmlDictionaryString wsrmNs = WsrmIndex.GetNamespace(reliableMessagingVersion); reader.ReadStartElement(); reader.ReadStartElement(wsrmFeb2005Dictionary.Identifier, wsrmNs); UniqueId sequenceID = reader.ReadContentAsUniqueId(); reader.ReadEndElement(); reader.ReadStartElement(wsrmFeb2005Dictionary.MessageNumber, wsrmNs); Int64 sequenceNumber = WsrmUtilities.ReadSequenceNumber(reader); reader.ReadEndElement(); bool lastMessage = false; if (reliableMessagingVersion == ReliableMessagingVersion.WSReliableMessagingFebruary2005) { if (reader.IsStartElement(wsrmFeb2005Dictionary.LastMessage, wsrmNs)) { WsrmUtilities.ReadEmptyElement(reader); lastMessage = true; } } while (reader.IsStartElement()) { reader.Skip(); } reader.ReadEndElement(); return new WsrmSequencedMessageInfo(sequenceID, sequenceNumber, lastMessage, header); }
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" }))); } }