Search code examples
wcfwshttpbinding

Read SOAP message header WCF


I have a WCF service with ws-security using wsHttpBinding. In one of my method, I want to read the ws-security SOAP header. How do I do it?

I have visited this link but not getting idea. I simply want to read the soap header in one of the operation contract in my WCF service. Is it possible to receive a soap message in a WCF method?

Thanks, Jay


Solution

  • Jay,

    Yes is possible to receive a SOAP message in a WCF method, but what I think you want is to read the header variables in the inbound request.

    On the host side, create an object from this:

    System.ServiceModel.OperationContext.Current.IncomingMessageHeaders
    

    This will return an indexed collection of the inbound message headers sent from the client, and you can read it this way:

    OpContext.IncomingMessageHeaders(0).ToString