I'd like to know what is the best way to display all MessageHeaders server side. Actually the only way I know is the following:
OperationContext.Current.IncomingMessageHeaders.GetHeader<T>开发者_Python百科(Name, Namespace)
That method is only for a known MessageHeader but I'd like to display their values in a loop.
Thank You
The headers are loopable:
for (int i = 0; i < OperationContext.Current.IncomingMessageHeaders.Count; ++i)
{
MessageHeaderInfo h = OperationContext.Current.IncomingMessageHeaders[i];
// for any reference parameters with the correct name & namespace
if (h.IsReferenceParameter &&
h.Name == IDName &&
h.Namespace == IDNamespace)
{
// read the value of that header
XmlReader xr = OperationContext.Current.IncomingMessageHeaders.GetReaderAtHeader(i);
id = xr.ReadElementContentAsString();
}
}
Found here
精彩评论