public RawFaultException(XmlDictionaryReader reader) : base("The service returned a fault - see FaultMessage, FaultStackTrace, and FaultType.") { reader.ReadToFollowing("Message"); m_faultMessage = reader.ReadElementContentAsString(); m_stackTrace = reader.ReadElementContentAsString("StackTrace", reader.NamespaceURI); m_type = Type.GetType(reader.ReadElementContentAsString("Type", reader.NamespaceURI)); }
public override object ReadObject(XmlDictionaryReader reader, bool verifyObjectName) { if (this.isCustomSerialization) { object result = Activator.CreateInstance(this.type); byte[] contents; if (m_IsCompress) { contents = reader.ReadElementContentAsBinHex(); } else { switch (m_ContentType) { case SerializeContentTypes.BinHex: contents = reader.ReadElementContentAsBinHex(); break; case SerializeContentTypes.String: contents = Encoding.UTF8.GetBytes(reader.ReadElementContentAsString()); break; default: contents = Encoding.UTF8.GetBytes(reader.ReadElementContentAsString()); break; } } using (MemoryStream ms = new MemoryStream(contents)) { DataContractJsonSerializer ser = new DataContractJsonSerializer(this.type); if (m_IsCompress) { using (DeflateStream ds = new DeflateStream(ms, CompressionMode.Decompress)) { result = ser.ReadObject(ds); ds.Close(); } } else { result = ser.ReadObject(ms); } ms.Close(); ser = null; return result; } } else { return this.fallbackSerializer.ReadObject(reader, verifyObjectName); } }
public static UserSoapHeader FromReader(XmlDictionaryReader reader) { UserSoapHeader header = new UserSoapHeader(); while (!reader.EOF) { if (reader.Name == "token") header.Token = reader.ReadElementContentAsString(); else if (reader.Name == "lan") header.Lan = reader.ReadElementContentAsString(); else if (reader.Name == "SOAP-ENV:Body") break; else reader.Read(); } return header; }
public override object ReadObject(XmlDictionaryReader reader, bool verifyObjectName) { string content = reader.ReadElementContentAsString(); var data = Convert.FromBase64String(content); if (UseEncryption()) data = Decrypt(data); var graph = Deserialize(data); return graph; }
public static string ReadHeaderValue(XmlDictionaryReader reader, AddressingVersion addressingVersion) { string s = reader.ReadElementContentAsString(); if ((s.Length <= 0) || ((s[0] > ' ') && (s[s.Length - 1] > ' '))) { return s; } return XmlUtil.Trim(s); }
/// <summary> /// 解析Message的头 /// </summary> /// <param name="reader"></param> /// <returns></returns> public static ExceptionSoapHeader FromReader(XmlDictionaryReader reader) { ExceptionSoapHeader header = new ExceptionSoapHeader(); while (!reader.EOF) { reader.Read(); if (reader.Name == "type" && reader.IsStartElement()) header.ExceptionType = (SoapExceptionType)Enum.Parse(typeof(SoapExceptionType), reader.ReadElementContentAsString()); else if (reader.Name == "message" && reader.IsStartElement()) header.Message = reader.ReadElementContentAsString(); else if (reader.Name == "stack" && reader.IsStartElement()) header.Stack = reader.ReadElementContentAsString(); else if (reader.Name == "appversion" && reader.IsStartElement()) header.AppVersion = reader.ReadElementContentAsString(); else continue; } return header; }
public static Uri ReadHeaderValue(XmlDictionaryReader reader, AddressingVersion version, UriCache uriCache) { string uriString = reader.ReadElementContentAsString(); if (uriString == version.Anonymous) { return version.AnonymousUri; } if (uriCache == null) { return new Uri(uriString); } return uriCache.CreateUri(uriString); }
public static MakeConnectionMessageInfo Create(XmlDictionaryReader reader) { MakeConnectionMessageInfo makeConnectionInfo = new MakeConnectionMessageInfo(); if (reader.IsStartElement(MakeConnectionConstants.MakeConnectionMessage.Name, MakeConnectionConstants.Namespace)) { reader.ReadStartElement(); reader.MoveToContent(); while (reader.IsStartElement()) { if (reader.IsStartElement(MakeConnectionConstants.MakeConnectionMessage.AddressElement, MakeConnectionConstants.Namespace)) { if (!string.IsNullOrEmpty(makeConnectionInfo.Address)) { makeConnectionInfo.MultipleAddressHeaders = true; reader.Skip(); } else { makeConnectionInfo.Address = reader.ReadElementContentAsString(); } } else if (reader.IsStartElement(MakeConnectionConstants.MakeConnectionMessage.IdentifierElement, MakeConnectionConstants.Namespace)) { if (makeConnectionInfo.Identifier != null) { makeConnectionInfo.MultipleIdentifierHeaders = true; reader.Skip(); } else { makeConnectionInfo.Identifier = reader.ReadElementContentAsUniqueId(); } } else { if (string.IsNullOrEmpty(makeConnectionInfo.UnknownSelection)) { makeConnectionInfo.UnknownSelection = reader.LocalName; } reader.Skip(); } } reader.ReadEndElement(); } return makeConnectionInfo; }
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; }
object ReadHeaderObject (Type type, XmlObjectSerializer serializer, XmlDictionaryReader reader) { // FIXME: it's a nasty workaround just to avoid UniqueId output as a string. // Seealso MessageHeader.DefaultMessageHeader.OnWriteHeaderContents(). // Note that msg.Headers.GetHeader<UniqueId> () simply fails (on .NET too) and it is useless. The API is lame by design. if (type == typeof (UniqueId)) return new UniqueId (reader.ReadElementContentAsString ()); else return serializer.ReadObject (reader); }
public static Uri ReadHeaderValue(XmlDictionaryReader reader, AddressingVersion version, UriCache uriCache) { Fx.Assert(reader.IsStartElement(XD.AddressingDictionary.To, version.DictionaryNamespace), ""); string toString = reader.ReadElementContentAsString(); if ((object)toString == (object)version.Anonymous) { return version.AnonymousUri; } if (uriCache == null) { return new Uri(toString); } return uriCache.CreateUri(toString); }
public override SecurityToken ReadTokenCore(XmlDictionaryReader reader, SecurityTokenResolver tokenResolver) { string wsuId = reader.GetAttribute(XD.UtilityDictionary.IdAttribute, XD.UtilityDictionary.Namespace); string valueTypeUri = reader.GetAttribute(ValueTypeAttribute, null); string encoding = reader.GetAttribute(EncodingTypeAttribute, null); byte[] binaryData; if (encoding == null || encoding == EncodingTypeValueBase64Binary) { binaryData = reader.ReadElementContentAsBase64(); } else if (encoding == EncodingTypeValueHexBinary) { binaryData = HexBinary.Parse(reader.ReadElementContentAsString()).Value; } else { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new MessageSecurityException(SR.GetString(SR.UnknownEncodingInBinarySecurityToken))); } return ReadBinaryCore(wsuId, valueTypeUri, binaryData); }
object ReadMessagePart (MessagePartDescription part, XmlDictionaryReader r) { if (part.Type == typeof (Stream)) // FIXME: it seems TransferMode.Streamed* has different serialization than .Buffered. Need to differentiate serialization somewhere (not limited to here). return new MemoryStream (Convert.FromBase64String (r.ReadElementContentAsString (part.Name, part.Namespace))); else return GetSerializer (part).ReadObject (r); }
public static object Deserialize(XmlDictionaryReader reader, Type targetType) { object returnValue = null; if (reader.IsStartElement()) { switch (reader.LocalName) { case XmlRpcProtocol.Nil: returnValue = null; break; case XmlRpcProtocol.Bool: returnValue = Convert.ChangeType((reader.ReadElementContentAsInt()==1),targetType); break; case XmlRpcProtocol.ByteArray: if (targetType == typeof(Stream)) { returnValue = new MemoryStream(reader.ReadElementContentAsBase64()); } else { returnValue = Convert.ChangeType(reader.ReadElementContentAsBase64(), targetType); } break; case XmlRpcProtocol.DateTime: returnValue = Convert.ChangeType(reader.ReadElementContentAsDateTime(),targetType); break; case XmlRpcProtocol.Double: returnValue = Convert.ChangeType(reader.ReadElementContentAsDouble(),targetType); break; case XmlRpcProtocol.Int32: case XmlRpcProtocol.Integer: returnValue = Convert.ChangeType(reader.ReadElementContentAsString(),targetType); break; case XmlRpcProtocol.String: if (targetType == typeof(Uri)) { returnValue = new Uri(reader.ReadElementContentAsString()); } else { returnValue = Convert.ChangeType(reader.ReadElementContentAsString(), targetType); } break; case XmlRpcProtocol.Struct: returnValue = DeserializeStruct(reader, targetType); break; case XmlRpcProtocol.Array: if (targetType.IsArray || targetType is IEnumerable || targetType is IList || targetType is ICollection) { reader.ReadStartElement(XmlRpcProtocol.Array); ArrayList arrayData = new ArrayList(); reader.ReadStartElement(XmlRpcProtocol.Data); reader.MoveToContent(); while (reader.IsStartElement(XmlRpcProtocol.Value)) { reader.ReadStartElement(); arrayData.Add(Deserialize(reader, targetType.GetElementType())); reader.ReadEndElement(); reader.MoveToContent(); } if (reader.NodeType == XmlNodeType.EndElement && reader.LocalName == XmlRpcProtocol.Data) { reader.ReadEndElement(); } reader.ReadEndElement(); if (targetType is IEnumerable || targetType is IList || targetType is ICollection) { returnValue = arrayData; } else { returnValue = arrayData.ToArray(targetType.GetElementType()); } } else { throw new InvalidOperationException(); } break; } } return returnValue; }
private static void ReadFrom(CoordinationContext that, XmlDictionaryReader reader, XmlDictionaryString localName, XmlDictionaryString ns, Microsoft.Transactions.Wsat.Protocol.ProtocolVersion protocolVersion) { try { Uri uri; CoordinationXmlDictionaryStrings strings = CoordinationXmlDictionaryStrings.Version(protocolVersion); AtomicTransactionStrings strings2 = AtomicTransactionStrings.Version(protocolVersion); reader.ReadFullStartElement(localName, strings.Namespace); reader.MoveToStartElement(strings.Identifier, strings.Namespace); that.unknownIdentifierAttributes = ReadOtherAttributes(reader, strings.Namespace); that.contextId = reader.ReadElementContentAsString().Trim(); if ((that.contextId.Length == 0) || (that.contextId.Length > 0x100)) { throw Microsoft.Transactions.Bridge.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidCoordinationContextException(Microsoft.Transactions.SR.GetString("InvalidCoordinationContext"))); } if (!Uri.TryCreate(that.contextId, UriKind.Absolute, out uri)) { throw Microsoft.Transactions.Bridge.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidCoordinationContextException(Microsoft.Transactions.SR.GetString("InvalidCoordinationContext"))); } if (reader.IsStartElement(strings.Expires, strings.Namespace)) { that.unknownExpiresAttributes = ReadOtherAttributes(reader, strings.Namespace); int num = reader.ReadElementContentAsInt(); if (num < 0) { throw Microsoft.Transactions.Bridge.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidCoordinationContextException(Microsoft.Transactions.SR.GetString("InvalidCoordinationContext"))); } that.expiration = (uint) num; that.expiresPresent = true; } reader.MoveToStartElement(strings.CoordinationType, strings.Namespace); if (reader.ReadElementContentAsString().Trim() != strings2.Namespace) { throw Microsoft.Transactions.Bridge.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidCoordinationContextException(Microsoft.Transactions.SR.GetString("InvalidCoordinationContext"))); } that.registrationRef = EndpointAddress.ReadFrom(MessagingVersionHelper.AddressingVersion(protocolVersion), reader, strings.RegistrationService, strings.Namespace); if (reader.IsStartElement(XD.DotNetAtomicTransactionExternalDictionary.IsolationLevel, XD.DotNetAtomicTransactionExternalDictionary.Namespace)) { that.isoLevel = (System.Transactions.IsolationLevel) reader.ReadElementContentAsInt(); if (((that.IsolationLevel < System.Transactions.IsolationLevel.Serializable) || (that.IsolationLevel > System.Transactions.IsolationLevel.Unspecified)) || (that.IsolationLevel == System.Transactions.IsolationLevel.Snapshot)) { throw Microsoft.Transactions.Bridge.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidCoordinationContextException(Microsoft.Transactions.SR.GetString("InvalidCoordinationContext"))); } } if (reader.IsStartElement(XD.DotNetAtomicTransactionExternalDictionary.IsolationFlags, XD.DotNetAtomicTransactionExternalDictionary.Namespace)) { that.isoFlags = (System.ServiceModel.Transactions.IsolationFlags) reader.ReadElementContentAsInt(); } if (reader.IsStartElement(XD.DotNetAtomicTransactionExternalDictionary.Description, XD.DotNetAtomicTransactionExternalDictionary.Namespace)) { that.description = reader.ReadElementContentAsString().Trim(); } if (reader.IsStartElement(XD.DotNetAtomicTransactionExternalDictionary.LocalTransactionId, XD.DotNetAtomicTransactionExternalDictionary.Namespace)) { that.localTxId = reader.ReadElementContentAsGuid(); } if (OleTxTransactionHeader.IsStartPropagationTokenElement(reader)) { that.propToken = OleTxTransactionHeader.ReadPropagationTokenElement(reader); } if (reader.IsStartElement()) { XmlDocument document = new XmlDocument(); that.unknownData = new List<System.Xml.XmlNode>(5); while (reader.IsStartElement()) { System.Xml.XmlNode item = document.ReadNode(reader); that.unknownData.Add(item); } } reader.ReadEndElement(); } catch (XmlException exception) { throw Microsoft.Transactions.Bridge.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidCoordinationContextException(Microsoft.Transactions.SR.GetString("InvalidCoordinationContext"), exception)); } }
public object ReadValue(XmlDictionaryReader reader) { object obj2; if (!this.isArray) { switch (this.typeCode) { case TypeCode.Int32: return reader.ReadElementContentAsInt(); case TypeCode.Int64: return reader.ReadElementContentAsLong(); case TypeCode.Single: return reader.ReadElementContentAsFloat(); case TypeCode.Double: return reader.ReadElementContentAsDouble(); case TypeCode.Decimal: return reader.ReadElementContentAsDecimal(); case TypeCode.DateTime: return reader.ReadElementContentAsDateTime(); case TypeCode.String: return reader.ReadElementContentAsString(); case TypeCode.Boolean: return reader.ReadElementContentAsBoolean(); } throw System.ServiceModel.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("SFxInvalidUseOfPrimitiveOperationFormatter"))); } switch (this.typeCode) { case TypeCode.Boolean: if (reader.IsEmptyElement) { reader.Read(); return new bool[0]; } reader.ReadStartElement(); obj2 = reader.ReadBooleanArray(this.itemName, this.itemNamespace); reader.ReadEndElement(); return obj2; case TypeCode.Byte: return reader.ReadElementContentAsBase64(); case TypeCode.Int32: if (reader.IsEmptyElement) { reader.Read(); return new int[0]; } reader.ReadStartElement(); obj2 = reader.ReadInt32Array(this.itemName, this.itemNamespace); reader.ReadEndElement(); return obj2; case TypeCode.Int64: if (reader.IsEmptyElement) { reader.Read(); return new long[0]; } reader.ReadStartElement(); obj2 = reader.ReadInt64Array(this.itemName, this.itemNamespace); reader.ReadEndElement(); return obj2; case TypeCode.Single: if (reader.IsEmptyElement) { reader.Read(); return new float[0]; } reader.ReadStartElement(); obj2 = reader.ReadSingleArray(this.itemName, this.itemNamespace); reader.ReadEndElement(); return obj2; case TypeCode.Double: if (reader.IsEmptyElement) { reader.Read(); return new double[0]; } reader.ReadStartElement(); obj2 = reader.ReadDoubleArray(this.itemName, this.itemNamespace); reader.ReadEndElement(); return obj2; case TypeCode.Decimal: if (reader.IsEmptyElement) { reader.Read(); return new decimal[0]; } reader.ReadStartElement(); obj2 = reader.ReadDecimalArray(this.itemName, this.itemNamespace); reader.ReadEndElement(); return obj2; case TypeCode.DateTime: if (reader.IsEmptyElement) { reader.Read(); return new DateTime[0]; } reader.ReadStartElement(); obj2 = reader.ReadDateTimeArray(this.itemName, this.itemNamespace); reader.ReadEndElement(); return obj2; } throw System.ServiceModel.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("SFxInvalidUseOfPrimitiveOperationFormatter"))); }
static bool ReadContentsFrom200408(XmlDictionaryReader reader, out Uri uri, out AddressHeaderCollection headers, out EndpointIdentity identity, out XmlBuffer buffer, out int metadataSection, out int extensionSection, out int pspSection) { buffer = null; headers = null; extensionSection = -1; metadataSection = -1; pspSection = -1; // Cache address string reader.MoveToContent(); if (!reader.IsStartElement(XD.AddressingDictionary.Address, AddressingVersion.WSAddressingAugust2004.DictionaryNamespace)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(CreateXmlException(reader, SR.GetString(SR.UnexpectedElementExpectingElement, reader.LocalName, reader.NamespaceURI, XD.AddressingDictionary.Address.Value, XD.Addressing200408Dictionary.Namespace.Value))); } string address = reader.ReadElementContentAsString(); // ReferenceProperites reader.MoveToContent(); if (reader.IsStartElement(XD.AddressingDictionary.ReferenceProperties, AddressingVersion.WSAddressingAugust2004.DictionaryNamespace)) { headers = AddressHeaderCollection.ReadServiceParameters(reader, true); } // ReferenceParameters reader.MoveToContent(); if (reader.IsStartElement(XD.AddressingDictionary.ReferenceParameters, AddressingVersion.WSAddressingAugust2004.DictionaryNamespace)) { if (headers != null) { List<AddressHeader> headerList = new List<AddressHeader>(); foreach (AddressHeader ah in headers) { headerList.Add(ah); } AddressHeaderCollection tmp = AddressHeaderCollection.ReadServiceParameters(reader); foreach (AddressHeader ah in tmp) { headerList.Add(ah); } headers = new AddressHeaderCollection(headerList); } else { headers = AddressHeaderCollection.ReadServiceParameters(reader); } } XmlDictionaryWriter bufferWriter = null; // PortType reader.MoveToContent(); if (reader.IsStartElement(XD.AddressingDictionary.PortType, AddressingVersion.WSAddressingAugust2004.DictionaryNamespace)) { if (bufferWriter == null) { if (buffer == null) buffer = new XmlBuffer(short.MaxValue); bufferWriter = buffer.OpenSection(reader.Quotas); bufferWriter.WriteStartElement(DummyName, DummyNamespace); } bufferWriter.WriteNode(reader, true); } // ServiceName reader.MoveToContent(); if (reader.IsStartElement(XD.AddressingDictionary.ServiceName, AddressingVersion.WSAddressingAugust2004.DictionaryNamespace)) { if (bufferWriter == null) { if (buffer == null) buffer = new XmlBuffer(short.MaxValue); bufferWriter = buffer.OpenSection(reader.Quotas); bufferWriter.WriteStartElement(DummyName, DummyNamespace); } bufferWriter.WriteNode(reader, true); } // Policy reader.MoveToContent(); while (reader.IsNamespaceUri(XD.PolicyDictionary.Namespace)) { if (bufferWriter == null) { if (buffer == null) buffer = new XmlBuffer(short.MaxValue); bufferWriter = buffer.OpenSection(reader.Quotas); bufferWriter.WriteStartElement(DummyName, DummyNamespace); } bufferWriter.WriteNode(reader, true); reader.MoveToContent(); } // Finish PSP if (bufferWriter != null) { bufferWriter.WriteEndElement(); buffer.CloseSection(); pspSection = buffer.SectionCount - 1; bufferWriter = null; } else { pspSection = -1; } // Metadata if (reader.IsStartElement(System.ServiceModel.Description.MetadataStrings.MetadataExchangeStrings.Metadata, System.ServiceModel.Description.MetadataStrings.MetadataExchangeStrings.Namespace)) { if (bufferWriter == null) { if (buffer == null) buffer = new XmlBuffer(short.MaxValue); bufferWriter = buffer.OpenSection(reader.Quotas); bufferWriter.WriteStartElement(DummyName, DummyNamespace); } bufferWriter.WriteNode(reader, true); } // Finish metadata if (bufferWriter != null) { bufferWriter.WriteEndElement(); buffer.CloseSection(); metadataSection = buffer.SectionCount - 1; bufferWriter = null; } else { metadataSection = -1; } // Extensions reader.MoveToContent(); buffer = ReadExtensions(reader, AddressingVersion.WSAddressingAugust2004, buffer, out identity, out extensionSection); // Finished reading if (buffer != null) buffer.Close(); // Process Address if (address == Addressing200408Strings.Anonymous) { uri = AddressingVersion.WSAddressingAugust2004.AnonymousUri; if (headers == null && identity == null) return true; } else { if (!Uri.TryCreate(address, UriKind.Absolute, out uri)) throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(SR.GetString(SR.InvalidUriValue, address, XD.AddressingDictionary.Address.Value, AddressingVersion.WSAddressingAugust2004.Namespace))); } return false; }
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; }
public virtual void ReadXml (XmlDictionaryReader reader, SamlSerializer samlSerializer, SecurityTokenSerializer keyInfoTokenSerializer, SecurityTokenResolver outOfBandTokenResolver) { if (reader == null) throw new ArgumentNullException ("reader"); if (samlSerializer == null) throw new ArgumentNullException ("samlSerializer"); reader.ReadStartElement ("Subject", SamlConstants.Namespace); NameFormat = reader.GetAttribute ("Format"); NameQualifier = reader.GetAttribute ("NameQualifier"); Name = reader.ReadElementContentAsString ("NameIdentifier", SamlConstants.Namespace); reader.ReadEndElement (); if (Name == null || Name.Length == 0) throw new SecurityTokenException ("non-zero length string must be exist for Name."); }
public object ReadValue(XmlDictionaryReader reader) { object value; if (_isArray) { switch (_typeCode) { case TypeCode.Byte: value = reader.ReadElementContentAsBase64(); break; case TypeCode.Boolean: if (!reader.IsEmptyElement) { reader.ReadStartElement(); value = reader.ReadBooleanArray(_itemName, _itemNamespace); reader.ReadEndElement(); } else { reader.Read(); value = Array.Empty<bool>(); } break; case TypeCode.DateTime: if (!reader.IsEmptyElement) { reader.ReadStartElement(); value = reader.ReadDateTimeArray(_itemName, _itemNamespace); reader.ReadEndElement(); } else { reader.Read(); value = Array.Empty<DateTime>(); } break; case TypeCode.Decimal: if (!reader.IsEmptyElement) { reader.ReadStartElement(); value = reader.ReadDecimalArray(_itemName, _itemNamespace); reader.ReadEndElement(); } else { reader.Read(); value = Array.Empty<Decimal>(); } break; case TypeCode.Int32: if (!reader.IsEmptyElement) { reader.ReadStartElement(); value = reader.ReadInt32Array(_itemName, _itemNamespace); reader.ReadEndElement(); } else { reader.Read(); value = Array.Empty<Int32>(); } break; case TypeCode.Int64: if (!reader.IsEmptyElement) { reader.ReadStartElement(); value = reader.ReadInt64Array(_itemName, _itemNamespace); reader.ReadEndElement(); } else { reader.Read(); value = Array.Empty<Int64>(); } break; case TypeCode.Single: if (!reader.IsEmptyElement) { reader.ReadStartElement(); value = reader.ReadSingleArray(_itemName, _itemNamespace); reader.ReadEndElement(); } else { reader.Read(); value = Array.Empty<Single>(); } break; case TypeCode.Double: if (!reader.IsEmptyElement) { reader.ReadStartElement(); value = reader.ReadDoubleArray(_itemName, _itemNamespace); reader.ReadEndElement(); } else { reader.Read(); value = Array.Empty<Double>(); } break; default: throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.SFxInvalidUseOfPrimitiveOperationFormatter)); } } else { switch (_typeCode) { case TypeCode.Boolean: value = reader.ReadElementContentAsBoolean(); break; case TypeCode.DateTime: value = reader.ReadElementContentAsDateTime(); break; case TypeCode.Decimal: value = reader.ReadElementContentAsDecimal(); break; case TypeCode.Double: value = reader.ReadElementContentAsDouble(); break; case TypeCode.Int32: value = reader.ReadElementContentAsInt(); break; case TypeCode.Int64: value = reader.ReadElementContentAsLong(); break; case TypeCode.Single: value = reader.ReadElementContentAsFloat(); break; case TypeCode.String: return reader.ReadElementContentAsString(); default: throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.SFxInvalidUseOfPrimitiveOperationFormatter)); } } return value; }
private static bool ReadContentsFrom10(XmlDictionaryReader reader, out System.Uri uri, out AddressHeaderCollection headers, out EndpointIdentity identity, out XmlBuffer buffer, out int metadataSection, out int extensionSection) { buffer = null; extensionSection = -1; metadataSection = -1; if (!reader.IsStartElement(XD.AddressingDictionary.Address, XD.Addressing10Dictionary.Namespace)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(CreateXmlException(reader, System.ServiceModel.SR.GetString("UnexpectedElementExpectingElement", new object[] { reader.LocalName, reader.NamespaceURI, XD.AddressingDictionary.Address.Value, XD.Addressing10Dictionary.Namespace.Value }))); } string uriString = reader.ReadElementContentAsString(); if (reader.IsStartElement(XD.AddressingDictionary.ReferenceParameters, XD.Addressing10Dictionary.Namespace)) { headers = AddressHeaderCollection.ReadServiceParameters(reader); } else { headers = null; } if (reader.IsStartElement(XD.Addressing10Dictionary.Metadata, XD.Addressing10Dictionary.Namespace)) { reader.ReadFullStartElement(); buffer = new XmlBuffer(0x7fff); metadataSection = 0; XmlDictionaryWriter writer = buffer.OpenSection(reader.Quotas); writer.WriteStartElement("Dummy", "http://Dummy"); while ((reader.NodeType != XmlNodeType.EndElement) && !reader.EOF) { writer.WriteNode(reader, true); } writer.Flush(); buffer.CloseSection(); reader.ReadEndElement(); } buffer = ReadExtensions(reader, AddressingVersion.WSAddressing10, buffer, out identity, out extensionSection); if (buffer != null) { buffer.Close(); } if (uriString == "http://www.w3.org/2005/08/addressing/anonymous") { uri = AddressingVersion.WSAddressing10.AnonymousUri; if ((headers == null) && (identity == null)) { return true; } } else { if (uriString == "http://www.w3.org/2005/08/addressing/none") { uri = AddressingVersion.WSAddressing10.NoneUri; return false; } if (!System.Uri.TryCreate(uriString, UriKind.Absolute, out uri)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(System.ServiceModel.SR.GetString("InvalidUriValue", new object[] { uriString, XD.AddressingDictionary.Address.Value, XD.Addressing10Dictionary.Namespace.Value }))); } } return false; }
static bool ReadContentsFrom10(XmlDictionaryReader reader, out Uri uri, out AddressHeaderCollection headers, out EndpointIdentity identity, out XmlBuffer buffer, out int metadataSection, out int extensionSection) { buffer = null; extensionSection = -1; metadataSection = -1; // Cache address string if (!reader.IsStartElement(XD.AddressingDictionary.Address, XD.Addressing10Dictionary.Namespace)) throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(CreateXmlException(reader, SR.GetString(SR.UnexpectedElementExpectingElement, reader.LocalName, reader.NamespaceURI, XD.AddressingDictionary.Address.Value, XD.Addressing10Dictionary.Namespace.Value))); string address = reader.ReadElementContentAsString(); // Headers if (reader.IsStartElement(XD.AddressingDictionary.ReferenceParameters, XD.Addressing10Dictionary.Namespace)) { headers = AddressHeaderCollection.ReadServiceParameters(reader); } else { headers = null; } // Metadata if (reader.IsStartElement(XD.Addressing10Dictionary.Metadata, XD.Addressing10Dictionary.Namespace)) { reader.ReadFullStartElement(); // the wsa10:Metadata element is never stored in the buffer buffer = new XmlBuffer(short.MaxValue); metadataSection = 0; XmlDictionaryWriter writer = buffer.OpenSection(reader.Quotas); writer.WriteStartElement(DummyName, DummyNamespace); while (reader.NodeType != XmlNodeType.EndElement && !reader.EOF) { writer.WriteNode(reader, true); } writer.Flush(); buffer.CloseSection(); reader.ReadEndElement(); } // Extensions buffer = ReadExtensions(reader, AddressingVersion.WSAddressing10, buffer, out identity, out extensionSection); if (buffer != null) { buffer.Close(); } // Process Address if (address == Addressing10Strings.Anonymous) { uri = AddressingVersion.WSAddressing10.AnonymousUri; if (headers == null && identity == null) { return true; } } else if (address == Addressing10Strings.NoneAddress) { uri = AddressingVersion.WSAddressing10.NoneUri; return false; } else { if (!Uri.TryCreate(address, UriKind.Absolute, out uri)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(SR.GetString(SR.InvalidUriValue, address, XD.AddressingDictionary.Address.Value, XD.Addressing10Dictionary.Namespace.Value))); } } return false; }
public static string ReadHeaderValue(XmlDictionaryReader reader, AddressingVersion addressingVersion) { Fx.Assert(reader.IsStartElement(XD.AddressingDictionary.Action, addressingVersion.DictionaryNamespace), ""); string act = reader.ReadElementContentAsString(); if (act.Length > 0 && (act[0] <= 32 || act[act.Length - 1] <= 32)) act = XmlUtil.Trim(act); return act; }
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))); } }
private static bool ReadContentsFrom200408(XmlDictionaryReader reader, out System.Uri uri, out AddressHeaderCollection headers, out EndpointIdentity identity, out XmlBuffer buffer, out int metadataSection, out int extensionSection, out int pspSection) { buffer = null; headers = null; extensionSection = -1; metadataSection = -1; pspSection = -1; reader.MoveToContent(); if (!reader.IsStartElement(XD.AddressingDictionary.Address, AddressingVersion.WSAddressingAugust2004.DictionaryNamespace)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(CreateXmlException(reader, System.ServiceModel.SR.GetString("UnexpectedElementExpectingElement", new object[] { reader.LocalName, reader.NamespaceURI, XD.AddressingDictionary.Address.Value, XD.Addressing200408Dictionary.Namespace.Value }))); } string uriString = reader.ReadElementContentAsString(); reader.MoveToContent(); if (reader.IsStartElement(XD.AddressingDictionary.ReferenceProperties, AddressingVersion.WSAddressingAugust2004.DictionaryNamespace)) { headers = AddressHeaderCollection.ReadServiceParameters(reader, true); } reader.MoveToContent(); if (reader.IsStartElement(XD.AddressingDictionary.ReferenceParameters, AddressingVersion.WSAddressingAugust2004.DictionaryNamespace)) { if (headers != null) { List<AddressHeader> addressHeaders = new List<AddressHeader>(); foreach (AddressHeader header in headers) { addressHeaders.Add(header); } foreach (AddressHeader header2 in AddressHeaderCollection.ReadServiceParameters(reader)) { addressHeaders.Add(header2); } headers = new AddressHeaderCollection(addressHeaders); } else { headers = AddressHeaderCollection.ReadServiceParameters(reader); } } XmlDictionaryWriter writer = null; reader.MoveToContent(); if (reader.IsStartElement(XD.AddressingDictionary.PortType, AddressingVersion.WSAddressingAugust2004.DictionaryNamespace)) { if (writer == null) { if (buffer == null) { buffer = new XmlBuffer(0x7fff); } writer = buffer.OpenSection(reader.Quotas); writer.WriteStartElement("Dummy", "http://Dummy"); } writer.WriteNode(reader, true); } reader.MoveToContent(); if (reader.IsStartElement(XD.AddressingDictionary.ServiceName, AddressingVersion.WSAddressingAugust2004.DictionaryNamespace)) { if (writer == null) { if (buffer == null) { buffer = new XmlBuffer(0x7fff); } writer = buffer.OpenSection(reader.Quotas); writer.WriteStartElement("Dummy", "http://Dummy"); } writer.WriteNode(reader, true); } reader.MoveToContent(); while (reader.IsNamespaceUri(XD.PolicyDictionary.Namespace)) { if (writer == null) { if (buffer == null) { buffer = new XmlBuffer(0x7fff); } writer = buffer.OpenSection(reader.Quotas); writer.WriteStartElement("Dummy", "http://Dummy"); } writer.WriteNode(reader, true); reader.MoveToContent(); } if (writer != null) { writer.WriteEndElement(); buffer.CloseSection(); pspSection = buffer.SectionCount - 1; writer = null; } else { pspSection = -1; } if (reader.IsStartElement("Metadata", "http://schemas.xmlsoap.org/ws/2004/09/mex")) { if (writer == null) { if (buffer == null) { buffer = new XmlBuffer(0x7fff); } writer = buffer.OpenSection(reader.Quotas); writer.WriteStartElement("Dummy", "http://Dummy"); } writer.WriteNode(reader, true); } if (writer != null) { writer.WriteEndElement(); buffer.CloseSection(); metadataSection = buffer.SectionCount - 1; writer = null; } else { metadataSection = -1; } reader.MoveToContent(); buffer = ReadExtensions(reader, AddressingVersion.WSAddressingAugust2004, buffer, out identity, out extensionSection); if (buffer != null) { buffer.Close(); } if (uriString == "http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous") { uri = AddressingVersion.WSAddressingAugust2004.AnonymousUri; if ((headers == null) && (identity == null)) { return true; } } else if (!System.Uri.TryCreate(uriString, UriKind.Absolute, out uri)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(System.ServiceModel.SR.GetString("InvalidUriValue", new object[] { uriString, XD.AddressingDictionary.Address.Value, AddressingVersion.WSAddressingAugust2004.Namespace }))); } return false; }
static WsatRegistrationHeader ReadFrom(XmlDictionaryReader reader) { reader.ReadFullStartElement(XD.DotNetAtomicTransactionExternalDictionary.RegisterInfo, XD.DotNetAtomicTransactionExternalDictionary.Namespace); reader.MoveToStartElement(XD.DotNetAtomicTransactionExternalDictionary.LocalTransactionId, XD.DotNetAtomicTransactionExternalDictionary.Namespace); // TransactionId Guid transactionId = reader.ReadElementContentAsGuid(); if (transactionId == Guid.Empty) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError( new XmlException(SR.GetString(SR.InvalidRegistrationHeaderTransactionId))); } // ContextId string contextId; if (reader.IsStartElement(XD.DotNetAtomicTransactionExternalDictionary.ContextId, XD.DotNetAtomicTransactionExternalDictionary.Namespace)) { Uri uri; contextId = reader.ReadElementContentAsString().Trim(); if (contextId.Length == 0 || contextId.Length > CoordinationContext.MaxIdentifierLength || !Uri.TryCreate(contextId, UriKind.Absolute, out uri)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError( new XmlException(SR.GetString(SR.InvalidRegistrationHeaderIdentifier))); } } else { contextId = null; } // TokenId string tokenId; if (reader.IsStartElement(XD.DotNetAtomicTransactionExternalDictionary.TokenId, XD.DotNetAtomicTransactionExternalDictionary.Namespace)) { tokenId = reader.ReadElementContentAsString().Trim(); if (tokenId.Length == 0) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError( new XmlException(SR.GetString(SR.InvalidRegistrationHeaderTokenId))); } } else { tokenId = null; } // Skip unknown elements while (reader.IsStartElement()) { reader.Skip(); } reader.ReadEndElement(); return new WsatRegistrationHeader(transactionId, contextId, tokenId); }
static PollingDuplexSession ReadHeaderValue(XmlDictionaryReader reader) { string str = null; string str2 = null; if (reader.IsStartElement("Duplex", "http://schemas.microsoft.com/2008/04/netduplex")) { reader.ReadStartElement(); reader.MoveToContent(); while (reader.IsStartElement()) { if (reader.IsStartElement("SessionId", "http://schemas.microsoft.com/2008/04/netduplex")) { if (!string.IsNullOrEmpty(str2)) { throw new InvalidOperationException("Multiple sessionId elements in a duplex header."); } str2 = reader.ReadElementContentAsString(); if (string.IsNullOrEmpty(str2)) { throw new InvalidOperationException("Invalid sessionId element content in a duplex header."); } } else { if (reader.IsStartElement("Address", "http://schemas.microsoft.com/2008/04/netduplex")) { if (!string.IsNullOrEmpty(str)) { throw new InvalidOperationException("Multiple address elements in a duplex header."); } str = reader.ReadElementContentAsString(); if (string.IsNullOrEmpty(str)) { throw new InvalidOperationException("Invalid address element in a duplex header."); } continue; } if (reader.IsStartElement("CloseSession", "http://schemas.microsoft.com/2008/04/netduplex")) { reader.Skip(); continue; } reader.Skip(); } } reader.ReadEndElement(); } if (str == null) { throw new InvalidOperationException("Missing address in a duplex header."); } if (str2 == null) { throw new InvalidOperationException("Missing sessionId in a duplex header."); } return new PollingDuplexSession(str, str2); }
/// <summary> /// Parses the "X509IssuerSerial" element and generates a corresponding <see cref="X509IssuerSerialKeyIdentifierClause"/> instance. /// </summary> /// <param name="dictionaryReader">The <see cref="XmlDictionaryReader"/> currently positioning on the "X509IssuerSerial" element. </param> /// <returns>An instance of <see cref="X509IssuerSerialKeyIdentifierClause"/> created from the "X509IssuerSerial" element.</returns> private static SecurityKeyIdentifierClause CreateIssuerSerialKeyIdentifierClause(XmlDictionaryReader dictionaryReader) { dictionaryReader.ReadStartElement(XmlSignatureConstants.Elements.X509IssuerSerial, XmlSignatureConstants.Namespace); if (!dictionaryReader.IsStartElement(XmlSignatureConstants.Elements.X509IssuerName, XmlSignatureConstants.Namespace)) { throw DiagnosticUtility.ThrowHelperInvalidOperation(SR.GetString(SR.ID3032, dictionaryReader.LocalName, dictionaryReader.NamespaceURI, XmlSignatureConstants.Elements.X509IssuerName, XmlSignatureConstants.Namespace)); } string issuerName = dictionaryReader.ReadElementContentAsString(XmlSignatureConstants.Elements.X509IssuerName, XmlSignatureConstants.Namespace); if (!dictionaryReader.IsStartElement(XmlSignatureConstants.Elements.X509SerialNumber, XmlSignatureConstants.Namespace)) { throw DiagnosticUtility.ThrowHelperInvalidOperation(SR.GetString(SR.ID3032, dictionaryReader.LocalName, dictionaryReader.NamespaceURI, XmlSignatureConstants.Elements.X509SerialNumber, XmlSignatureConstants.Namespace)); } string serialNumber = dictionaryReader.ReadElementContentAsString(XmlSignatureConstants.Elements.X509SerialNumber, XmlSignatureConstants.Namespace); dictionaryReader.ReadEndElement(); // Reade the ending </X509IssuerSerial> element. return new X509IssuerSerialKeyIdentifierClause(issuerName, serialNumber); }
private static JsonPrimitive ReadPrimitive(string type, XmlDictionaryReader jsonReader) { JsonValue result = null; switch (type) { case NullAttributeValue: jsonReader.Skip(); result = null; break; case BooleanAttributeValue: result = jsonReader.ReadElementContentAsBoolean(); break; case StringAttributeValue: result = jsonReader.ReadElementContentAsString(); break; case NumberAttributeValue: string temp = jsonReader.ReadElementContentAsString(); result = ConvertStringToJsonNumber(temp); break; } SkipWhitespace(jsonReader); return (JsonPrimitive)result; }
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; }