using System.Xml.Serialization;
public static void Main()
var serializer = new XmlSerializer(typeof(SoapEnvelope));
var envelope = new SoapEnvelope
UsernameToken = new UsernameToken
"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#passwordtext",
var ns = new XmlSerializerNamespaces();
ns.Add("soap-env", "http://schemas.xmlsoap.org/soap/envelope/");
ns.Add("wsse", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd");
serializer.Serialize(Console.Out, envelope, ns);
[XmlRoot(ElementName = "Envelope", Namespace = "http://schemas.xmlsoap.org/soap/envelope/")]
public class SoapEnvelope
public Header Header { get; set; }
public UsernameToken GenericBody { get; set; }
[XmlRoot(ElementName = "Security", Namespace = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd")]
public Security Security { get; set; }
[XmlAttribute("mustunderstand", Namespace = "http://schemas.xmlsoap.org/soap/envelope/")]
public int MustUnderstand { get; set; }
public UsernameToken UsernameToken { get; set; }
public class UsernameToken
public string Username { get; set; }
public Passwords Password { get; set; }
public string Type { get; set; }
public string Password { get; set; }