How to get the value from MessageHeaderInfo
I am sending some SOAP headers to a WCF service and I am trying to catch them using behavior extension. When the message is received I am going thr开发者_JS百科ough its headers collection.
Each header is of MessageHeaderInfo type which does not have a value property. How can I extract the value? It can be done with an ugly parsing (to remove the xml elements around the value) but it feels lame.
your help is most appriciated!
The way you normally use message headers is by defining a DataContract (or an XmlSerializable class) to represent your header, then use Message.Headers.GetHeader<T>() to retrieve it. That method will do the deserialization and hand you a strongly typed object you can use.
精彩评论