/// <summary>
 /// Override the method to write the content to the xml dictionary writer.
 /// </summary>
 /// <param name="writer">Specify the output destination of the content.</param>
 protected override void OnWriteBodyContents(System.Xml.XmlDictionaryWriter writer)
 {
     byte[] bytes = new byte[this.stream.Length];
     this.stream.Position = 0;
     this.stream.Read(bytes, 0, bytes.Length);
     writer.WriteRaw(this.encoding.GetString(bytes));
 }
 protected override void OnWriteAddressHeaderContents(System.Xml.XmlDictionaryWriter writer)
 {
     // here you do what you want
     writer.WriteRaw(String.Format(@"
              <UsernameToken xmlns=""http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"">
              <Username>user</Username>
              <Password Type=""http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest"">pass</Password>
              </UsernameToken>").Trim());
 }