public WriteXmlnsAttribute ( string prefix, System namespaceUri ) : void | ||
prefix | string | |
namespaceUri | System | |
return | void |
protected override void OnWriteStartEnvelope(XmlDictionaryWriter writer) { base.OnWriteStartEnvelope(writer); writer.WriteXmlnsAttribute("addata", "http://schemas.microsoft.com/2008/1/ActiveDirectory/Data"); writer.WriteXmlnsAttribute("ad", "http://schemas.microsoft.com/2008/1/ActiveDirectory"); writer.WriteXmlnsAttribute("xsd", "http://www.w3.org/2001/XMLSchema"); writer.WriteXmlnsAttribute("xsi", "http://www.w3.org/2001/XMLSchema-instance"); if (writer.LookupPrefix("http://www.w3.org/2005/08/addressing") == null) { writer.WriteXmlnsAttribute("wsa", "http://www.w3.org/2005/08/addressing"); } }
protected virtual void AddPrefixIfNeeded(XmlDictionaryWriter writer, string prefix, string ns) { if (writer.LookupPrefix(ns) == null) { writer.WriteXmlnsAttribute(prefix, ns); } }
protected override void OnWriteStartHeader(XmlDictionaryWriter writer, MessageVersion messageVersion) { writer.WriteStartElement(this.Name, this.Namespace); writer.WriteXmlnsAttribute(null, _notUnderstoodNs); writer.WriteStartAttribute(Message12Strings.QName); writer.WriteQualifiedName(_notUnderstoodName, _notUnderstoodNs); writer.WriteEndAttribute(); }
internal static void AddNamespaceDeclaration(XmlDictionaryWriter writer, string prefix, XmlDictionaryString ns) { string p = writer.LookupPrefix(ns.Value); if (p == null || p != prefix) { writer.WriteXmlnsAttribute(prefix, ns); } }
internal static string EnsureNamespaceDefined(XmlDictionaryWriter writer, XmlDictionaryString ns, string defaultPrefix) { string p = writer.LookupPrefix(ns.Value); if (p == null) { writer.WriteXmlnsAttribute(defaultPrefix, ns); p = defaultPrefix; } return p; }
private void WriteHeader(XmlDictionaryWriter writer) { writer.WriteStartElement("wsse", "UsernameToken", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"); writer.WriteXmlnsAttribute("wsu", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"); writer.WriteStartElement("wsse", "Username", null); writer.WriteString(SystemUser); writer.WriteEndElement();//End Username writer.WriteStartElement("wsse", "Password", null); writer.WriteAttributeString("Type", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText"); writer.WriteString(SystemPassword); writer.WriteEndElement();//End Password writer.WriteEndElement();//End UsernameToken writer.Flush(); }
public void WriteContent(XmlDictionaryWriter writer) { if ((this.isoLevel != System.Transactions.IsolationLevel.Unspecified) || (this.localTxId != Guid.Empty)) { writer.WriteXmlnsAttribute("mstx", XD.DotNetAtomicTransactionExternalDictionary.Namespace); } writer.WriteStartElement(this.coordinationStrings.Prefix, this.coordinationXmlDictionaryStrings.Identifier, this.coordinationXmlDictionaryStrings.Namespace); if (this.unknownIdentifierAttributes != null) { foreach (System.Xml.XmlNode node in this.unknownIdentifierAttributes) { node.WriteTo(writer); } } writer.WriteString(this.contextId); writer.WriteEndElement(); if (this.expiresPresent) { writer.WriteStartElement(this.coordinationXmlDictionaryStrings.Expires, this.coordinationXmlDictionaryStrings.Namespace); if (this.unknownExpiresAttributes != null) { foreach (System.Xml.XmlNode node2 in this.unknownExpiresAttributes) { node2.WriteTo(writer); } } writer.WriteValue((long) this.expiration); writer.WriteEndElement(); } writer.WriteStartElement(this.coordinationXmlDictionaryStrings.CoordinationType, this.coordinationXmlDictionaryStrings.Namespace); writer.WriteString(this.atomicTransactionXmlDictionaryStrings.Namespace); writer.WriteEndElement(); this.registrationRef.WriteTo(MessagingVersionHelper.AddressingVersion(this.protocolVersion), writer, this.coordinationXmlDictionaryStrings.RegistrationService, this.coordinationXmlDictionaryStrings.Namespace); if (this.isoLevel != System.Transactions.IsolationLevel.Unspecified) { writer.WriteStartElement(XD.DotNetAtomicTransactionExternalDictionary.IsolationLevel, XD.DotNetAtomicTransactionExternalDictionary.Namespace); writer.WriteValue((int) this.isoLevel); writer.WriteEndElement(); } if (this.isoFlags != 0) { writer.WriteStartElement(XD.DotNetAtomicTransactionExternalDictionary.IsolationFlags, XD.DotNetAtomicTransactionExternalDictionary.Namespace); writer.WriteValue((int) this.isoFlags); writer.WriteEndElement(); } if (!string.IsNullOrEmpty(this.description)) { writer.WriteStartElement(XD.DotNetAtomicTransactionExternalDictionary.Description, XD.DotNetAtomicTransactionExternalDictionary.Namespace); writer.WriteValue(this.description); writer.WriteEndElement(); } if (this.localTxId != Guid.Empty) { writer.WriteStartElement(XD.DotNetAtomicTransactionExternalDictionary.LocalTransactionId, XD.DotNetAtomicTransactionExternalDictionary.Namespace); writer.WriteValue(this.localTxId); writer.WriteEndElement(); } if (this.propToken != null) { OleTxTransactionHeader.WritePropagationTokenElement(writer, this.propToken); } if (this.unknownData != null) { int count = this.unknownData.Count; for (int i = 0; i < count; i++) { this.unknownData[i].WriteTo(writer); } } }
protected override void OnWriteStartHeader(XmlDictionaryWriter writer, MessageVersion messageVersion) { writer.WriteStartElement("wsse", Name, Namespace); writer.WriteXmlnsAttribute("wsu", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"); writer.WriteAttributeString("s:mustUnderstand", "1"); }
protected override void OnWriteStartBody(XmlDictionaryWriter writer) { base.OnWriteStartBody(writer); writer.WriteXmlnsAttribute("wsen", "http://schemas.xmlsoap.org/ws/2004/09/enumeration"); writer.WriteXmlnsAttribute("adlq", "http://schemas.microsoft.com/2008/1/ActiveDirectory/Dialect/LdapQuery"); }
protected override void OnWriteHeaderContents(XmlDictionaryWriter writer, MessageVersion messageVersion) { writer.WriteStartElement("r", "FaultCode", this.Namespace); writer.WriteXmlnsAttribute(null, this.Namespace); writer.WriteQualifiedName(this.Subcode, this.Namespace); writer.WriteEndElement(); bool flag = base.ReliableMessagingVersion == ReliableMessagingVersion.WSReliableMessaging11; if (flag) { writer.WriteStartElement("r", XD.Message12Dictionary.FaultDetail, this.DictionaryNamespace); } this.fault.WriteDetail(writer); if (flag) { writer.WriteEndElement(); } }
/// <summary> /// Overwrites the default SOAP Security Header values generated by WCF with /// those required by the UserService which implements WSE 2.0. This is required /// for interoperability between a WCF Client and a WSE 2.0 Service. /// </summary> /// <param name="writer"><see cref="XmlDictionaryWriter"/></param> private void WriteHeader(XmlDictionaryWriter writer) { // Create the Nonce byte[] nonce = GenerateNonce(); // Create the Created Date string created = DateTime.UtcNow.ToString("yyyy-MM-ddTHH:mm:ss.fffZ"); // Create the WSSE Security Header, starting with the Username Element writer.WriteStartElement("wsse", "UsernameToken", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"); writer.WriteXmlnsAttribute("wsu", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"); writer.WriteStartElement("wsse", "Username", null); writer.WriteString(config.Username); writer.WriteEndElement(); // Add the Password Element writer.WriteStartElement("wsse", "Password", null); writer.WriteAttributeString("Type", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest"); writer.WriteString(GeneratePasswordDigest(nonce, created, config.Password)); writer.WriteEndElement(); // Add the Nonce Element writer.WriteStartElement("wsse", "Nonce", null); writer.WriteAttributeString("EncodingType", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary"); writer.WriteBase64(nonce, 0, nonce.Length); writer.WriteEndElement(); // Lastly, add the Created Element writer.WriteStartElement("wsu", "Created", null); writer.WriteString(created); writer.WriteEndElement(); writer.WriteEndElement(); writer.Flush(); }
protected override void OnWriteHeaderContents(XmlDictionaryWriter writer, MessageVersion messageVersion) { writer.WriteStartElement(WsrmFeb2005Strings.Prefix, WsrmFeb2005Strings.FaultCode, this.Namespace); writer.WriteXmlnsAttribute(null, this.Namespace); writer.WriteQualifiedName(this.Subcode, this.Namespace); writer.WriteEndElement(); bool wsrm11 = this.ReliableMessagingVersion == ReliableMessagingVersion.WSReliableMessaging11; if (wsrm11) { writer.WriteStartElement(WsrmFeb2005Strings.Prefix, XD.Message12Dictionary.FaultDetail, this.DictionaryNamespace); } this.fault.WriteDetail(writer); if (wsrm11) { writer.WriteEndElement(); } }
protected override void OnWriteStartBody(XmlDictionaryWriter writer) { base.OnWriteStartBody(writer); writer.WriteXmlnsAttribute("wsen", "http://schemas.xmlsoap.org/ws/2004/09/enumeration"); }
private void WriteHeader(XmlDictionaryWriter writer) { //Begin Variable setups var nonce = new byte[64]; RandomNumberGenerator.Create().GetBytes(nonce); string created = DateTime.Now.ToString("yyyy-MM-ddThh:mm:ss.msZ"); //End Variable setups // Write Namespace attributes on the "wsse:Security" Node writer.WriteXmlnsAttribute("wsse", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"); writer.WriteXmlnsAttribute("wsu", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"); // Begin UsernameToken Holder for UserName, Password, Nonce, and Created Nodes writer.WriteStartElement("wsse", "UsernameToken", null); writer.WriteAttributeString("wsu", "Id", null, "UsernameToken-2"); //Begin Username writer.WriteStartElement("wsse", "Username", null); writer.WriteString(SystemUser); writer.WriteEndElement(); //End Username //Begin Password Plaintext writer.WriteStartElement("wsse", "Password", null); if (this.SystermPasswordType == PasswordType.ClearText) { writer.WriteAttributeString("Type", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText"); writer.WriteString(SystemPassword); } else if (this.SystermPasswordType == PasswordType.Digest) { writer.WriteAttributeString("Type", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest"); writer.WriteString(ComputePasswordDigest(SystemPassword, nonce, created)); } writer.WriteEndElement(); //End Password Plaintext //Begin Password Nonce writer.WriteStartElement("wsse", "Nonce", null); writer.WriteAttributeString("EncodingType", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary"); writer.WriteBase64(nonce, 0, nonce.Length); writer.WriteEndElement(); //End Password Nonce //Begin Created writer.WriteStartElement("wsu", "Created", null); writer.WriteString(created); writer.WriteEndElement(); //End Created writer.WriteEndElement(); // Begin UsernameToken Holder writer.Flush(); }
/// <summary> /// This method is used to write a XML node to a XML writer. /// </summary> /// <param name="node">Specify the XML node.</param> /// <param name="writer">Specify the XML writer.</param> private void WriteNode(XmlNode node, XmlDictionaryWriter writer) { writer.WriteStartElement(node.Name); foreach (XmlAttribute xmlAttribute in node.Attributes) { writer.WriteAttributeString(xmlAttribute.Name, xmlAttribute.Value); if (!string.IsNullOrEmpty(xmlAttribute.Prefix)) { writer.WriteXmlnsAttribute(xmlAttribute.Prefix, xmlAttribute.NamespaceURI); } } if (node.Name == "SubRequestData") { string base64 = node.InnerText; byte[] bytes = Convert.FromBase64String(base64); writer.WriteBase64(bytes, 0, bytes.Length); } else { foreach (XmlNode childNode in node.ChildNodes) { this.WriteNode(childNode, writer); } } writer.WriteEndElement(); }
protected override void OnWriteStartFilterElement(XmlDictionaryWriter writer) { base.OnWriteStartFilterElement(writer); writer.WriteAttributeString("Dialect", "http://schemas.microsoft.com/2008/1/ActiveDirectory/Dialect/LdapQuery"); writer.WriteXmlnsAttribute("adlq", "http://schemas.microsoft.com/2008/1/ActiveDirectory/Dialect/LdapQuery"); }
protected override void OnWriteStartHeader(XmlDictionaryWriter writer, MessageVersion messageVersion) { writer.WriteStartElement(PREFIX_CP, Name, Namespace); writer.WriteXmlnsAttribute(PREFIX_CP, Namespace); writer.WriteAttributeString("SOAP-ENV:actor", "uri:orderUser"); }
protected override void OnWriteHeaderContents(XmlDictionaryWriter writer, MessageVersion messageVersion) { writer.WriteRaw(GetToken().OuterXml); writer.WriteStartElement("Timestamp"); writer.WriteXmlnsAttribute("", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"); writer.WriteAttributeString("Id", "Timestamp-79"); //Created writer.WriteStartElement("Created"); writer.WriteString(this.token.ValidFrom.ToString("yyyy-MM-ddTHH:mm:ssZ")); writer.WriteEndElement(); //Expires writer.WriteStartElement("Expires"); writer.WriteString(this.token.ValidTo.ToString("yyyy-MM-ddTHH:mm:ssZ")); writer.WriteEndElement(); writer.WriteEndElement(); }
protected override void OnWriteStartHeader(XmlDictionaryWriter writer, MessageVersion messageVersion) { writer.WriteStartElement("wsse", Name, Namespace); writer.WriteXmlnsAttribute("wsse", Namespace); }
public override void WriteStartObject ( XmlDictionaryWriter writer, object graph) { Type rootType = type; if (root_name.Value == "") throw new InvalidDataContractException ("Type '" + type.ToString () + "' cannot have a DataContract attribute Name set to null or empty string."); if (graph == null) { if (names_filled) writer.WriteStartElement (root_name.Value, root_ns.Value); else writer.WriteStartElement (root_name, root_ns); writer.WriteAttributeString ("i", "nil", XmlSchema.InstanceNamespace, "true"); return; } QName instName = null; QName root_qname = known_types.GetQName (rootType); QName graph_qname = known_types.GetQName (graph.GetType ()); known_types.Add (graph.GetType ()); if (names_filled) writer.WriteStartElement (root_name.Value, root_ns.Value); else writer.WriteStartElement (root_name, root_ns); if (root_ns.Value != root_qname.Namespace) if (root_qname.Namespace != KnownTypeCollection.MSSimpleNamespace) writer.WriteXmlnsAttribute (null, root_qname.Namespace); if (root_qname == graph_qname) { if (root_qname.Namespace != KnownTypeCollection.MSSimpleNamespace && !rootType.IsEnum) //FIXME: Hack, when should the "i:type" be written? //Not used in case of enums writer.WriteXmlnsAttribute ("i", XmlSchema.InstanceNamespace); return; } /* Different names */ known_types.Add (rootType); instName = KnownTypeCollection.GetPredefinedTypeName (graph.GetType ()); if (instName == QName.Empty) /* Not a primitive type */ instName = graph_qname; else /* FIXME: Hack, .. see test WriteObject7 () */ instName = new QName (instName.Name, XmlSchema.Namespace); // output xsi:type as rootType is not equivalent to the graph's type. writer.WriteStartAttribute ("i", "type", XmlSchema.InstanceNamespace); writer.WriteQualifiedName (instName.Name, instName.Namespace); writer.WriteEndAttribute (); }
public virtual void WriteXml ( XmlDictionaryWriter writer, SamlSerializer samlSerializer, SecurityTokenSerializer keyInfoSerializer) { if (writer == null) throw new ArgumentNullException ("writer"); if (samlSerializer == null) throw new ArgumentNullException ("samlSerializer"); if (AuthorityKind == null) throw new SecurityTokenException ("AuthorityKind must be set to SAML AuthorityBinding before being written."); if (Binding == null) throw new SecurityTokenException ("non-zero length Binding must be set to SAML AuthorityBinding before being written."); if (Location == null) throw new SecurityTokenException ("non-zero length Location must be set to SAML AuthorityBinding before being written."); writer.WriteStartElement ("saml", "AuthorityBinding", SamlConstants.Namespace); writer.WriteXmlnsAttribute (String.Empty, AuthorityKind.Namespace); writer.WriteAttributeString ("AuthorityKind", AuthorityKind.Name); writer.WriteAttributeString ("Location", Location); writer.WriteAttributeString ("Binding", Binding); writer.WriteEndElement (); }
protected override void OnWriteStartEnvelope(XmlDictionaryWriter writer) { base.OnWriteStartEnvelope(writer); writer.WriteXmlnsAttribute("da", "http://schemas.microsoft.com/2006/11/IdentityManagement/DirectoryAccess"); }
public override void WriteStartObject ( XmlDictionaryWriter writer, object graph) { Type rootType = type; if (root_name.Value == "") throw new InvalidDataContractException ("Type '" + type.ToString () + "' cannot have a DataContract attribute Name set to null or empty string."); if (graph == null) { if (names_filled) writer.WriteStartElement (root_name.Value, root_ns.Value); else writer.WriteStartElement (root_name, root_ns); writer.WriteAttributeString ("i", "nil", XmlSchema.InstanceNamespace, "true"); return; } QName rootQName = null; XmlDictionaryString name, ns; if (DataContractResolver != null && DataContractResolver.TryResolveType (graph.GetType (), type, default_resolver, out name, out ns)) rootQName = new QName (name.Value, ns.Value); // It is error unless 1) TypeResolver resolved the type name, 2) the object is the exact type, 3) the object is known or 4) the type is primitive. if (rootQName == null && graph.GetType () != type && IsUnknownType (graph.GetType ())) throw new SerializationException (String.Format ("Type '{0}' is unexpected. The type should either be registered as a known type, or DataContractResolver should be used.", graph.GetType ())); QName instName = rootQName; rootQName = rootQName ?? known_types.GetQName (rootType); QName graph_qname = known_types.GetQName (graph.GetType ()); known_types.Add (graph.GetType ()); if (names_filled) writer.WriteStartElement (root_name.Value, root_ns.Value); else writer.WriteStartElement (root_name, root_ns); if (rootQName != graph_qname || rootQName.Namespace != KnownTypeCollection.MSSimpleNamespace && !rootType.IsEnum) //FIXME: Hack, when should the "i:type" be written? //Not used in case of enums writer.WriteXmlnsAttribute ("i", XmlSchema.InstanceNamespace); if (root_ns.Value != rootQName.Namespace) if (rootQName.Namespace != KnownTypeCollection.MSSimpleNamespace) writer.WriteXmlnsAttribute (null, rootQName.Namespace); if (rootQName == graph_qname) return; /* Different names */ known_types.Add (rootType); instName = instName ?? KnownTypeCollection.GetPredefinedTypeName (graph.GetType ()); if (instName == QName.Empty) /* Not a primitive type */ instName = graph_qname; else /* FIXME: Hack, .. see test WriteObject7 () */ instName = new QName (instName.Name, XmlSchema.Namespace); /* // disabled as it now generates extraneous i:type output. // output xsi:type as rootType is not equivalent to the graph's type. writer.WriteStartAttribute ("i", "type", XmlSchema.InstanceNamespace); writer.WriteQualifiedName (instName.Name, instName.Namespace); writer.WriteEndAttribute (); */ }
protected override void OnWriteBodyContents (XmlDictionaryWriter writer) { if (writer.WriteState == WriteState.Element) { writer.WriteXmlnsAttribute ("xsi", XmlSchema.InstanceNamespace); writer.WriteXmlnsAttribute ("xsd", XmlSchema.Namespace); } serializer.Serialize (writer, body); }