views:

17

answers:

0

Can I add and read a custom header in the Envelope/Header/Security element? I tried using the MessageHeader attribute, but that does not allow me to put the header in the Security element.

I created a class that implements IClientMessageInspector thinking that I could access the Security header like so:

public object BeforeSendRequest(ref Message request, IClientChannel channel)
{
   MessageBuffer buffer = request.CreateBufferedCopy(Int32.MaxValue);
   request = buffer.CreateMessage();

   Message originalMessage = buffer.CreateMessage();
   foreach (MessageHeader h in originalMessage.Headers)
   {
      Console.WriteLine("\n{0}\n", h);
   }

   return null;
}

But the Security header is not present in the originalMessage.Headers object.