zoukankan      html  css  js  c++  java
  • 通过OperationContext添加消息头信息

    通过往WCF消息头中添加自定义信息,可以用于各种用途,比如可以用于传递AuthKey来判断调用是否合法。

    客户端:

                using (OperationContextScope scope = new OperationContextScope(iContextChannel))
                {
                    MessageHeader
    <string> mh = new MessageHeader<string>("abcde");
                    MessageHeader header 
    = mh.GetUntypedHeader("AuthKey""http://www.facebuyer.com");
                    OperationContext.Current.OutgoingMessageHeaders.Add(header);

                    
    return func();
                }

    服务端:

                string authKey = string.Empty;
                    
    if (OperationContext.Current != null)
                    {
                        authKey 
    = OperationContext.Current.IncomingMessageHeaders.GetHeader<string>("AuthKey""http://www.facebuyer.com");
                    }
  • 相关阅读:
    面向对象编程-介绍(python3入门)
    课堂作业03
    软件工程个人作业04
    团队介绍
    学习进度条
    课堂作业02
    学习进度条
    软件工程个人作业03
    课堂作业01
    软件工程个人作业02
  • 原文地址:https://www.cnblogs.com/chenjunbiao/p/1760317.html
Copyright © 2011-2022 走看看