开发者

Display all messageHeader's values

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜