How to prefix a XmlRoot object in c# for Serialise XML?
<p>I need make a Header for SOAP request. After search, I success to generate my Header request in XML but i need a prefix on my XML tag.</p>

<p>Actually, I have generated this :</p>

<pre><code>&lt;TimeStamp xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="TimeStamp-2"&gt;
   &lt;Created&gt;2016-03-22T10:10:55.710Z&lt;/Created&gt;
   &lt;Expires&gt;2016-03-22T11:10:55.710Z&lt;/Expires&gt;
&lt;/TimeStamp&gt;
</code></pre>

<p>And I need to have that :</p>

<pre><code>&lt;wsu:TimeStamp xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="TimeStamp-2"&gt;
   &lt;Created&gt;2016-03-22T10:10:55.710Z&lt;/Created&gt;
   &lt;Expires&gt;2016-03-22T11:10:55.710Z&lt;/Expires&gt;
&lt;/wsu:TimeStamp&gt;
</code></pre>

<p>I was inspired by this topic (<a href="https://stackoverflow.com/questions/16028014/how-can-i-pass-a-username-password-in-the-header-to-a-soap-wcf-service">How can I pass a username/password in the header to a SOAP WCF Service</a>) for create my class and generate my XML.</p>

<p>Here, there is my version :</p>

<pre><code>class SecurityHeader : MessageHeader
{

    public override string Name
    {
        get { return "Security"; }
    }

    public override string Namespace
    {
        get { return "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"; }
    }

    protected override void OnWriteHeaderContents(XmlDictionaryWriter writer, MessageVersion messageVersion)
    {
        XmlSerializerNamespaces ns = new XmlSerializerNamespaces();
        ns.Add("wsu", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd");
        XmlSerializer serializer1 = new XmlSerializer(typeof(TimeStamp));
        serializer1.Serialize(Console.Out, new TimeStamp(), ns);

    }
}

[XmlRoot("TimeStamp",Namespace = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd")]
public class TimeStamp
{
    public TimeStamp()
    {
        Id = "TimeStamp-2";
        Created = new Created() { Value = Created.GenerateTimeStampCreation() };
        Expires = new Expires() { Value = Expires.GenerateTimeStampExpiration() };
    }

    [XmlAttribute(Namespace = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd")]
    public string Id { get; set; }

    [XmlElement]
    public Created Created { get; set; }

    [XmlElement]
    public Expires Expires { get; set; }
}
</code></pre>