zoukankan      html  css  js  c++  java
  • 如何配置不启用安全的WCF服务

    [转]如何配置不启用安全的WCF服务?

    【1】问题描述: 一般WCF默认很多绑定是使用安全的,一般不是Transport(TcpBinding)就是Message(WSHttpBinding)安全模式。 而且会对客户端启用身份验证。 因为WCF安全设置与开发比较麻烦,所以大部分开发人员希望不启用安全模式。 那么如何做呢?

    【2】参考配置: 服务端首先可以设置SecurityMode=“None”。这个可以通过配置文件,也可以通过代码来实现。这里给出配置文件的方式。参考代码:

        <wsHttpBinding>
          <binding name="bindingConfiguration">
            <security mode="None">
              <transport clientCredentialType="None"/>
       <message clientCredentialType="None"/>
            </security>
          </binding>
        </wsHttpBinding>

    另外这里还要把这个绑定用到对应的Endpoint的配置上:

    bindingConfiguration="bindingConfiguration"

    例子如下:

            <endpoint
              address="WCFService"
              binding="wsHttpBinding"
              bindingConfiguration="bindingConfiguration"
              contract="WCFService.IWCFService">
            </endpoint>

    【3】Client配置: 客户端配置 也要与之对应,最好重新添加服务引用。更新客户端配置。 当然也可以自己手动更新,因为没有使用安全传输以及验证客户端。 所以客户端简化配置如下:

        <system.serviceModel>
            <bindings>
                <wsHttpBinding>
                    <binding name="WSHttpBinding_IWCFService" />
                        <security mode="None">
                            <transport clientCredentialType="None" />
                            <message clientCredentialType="None"  />
                        </security>
                    </binding>
                </wsHttpBinding>
            </bindings>
            <client>
                <endpoint address="https://frank-xu2009:9001/WCFService" binding="wsHttpBinding"
                    bindingConfiguration="WSHttpBinding_IWCFService" contract="ClientProxy.IWCFService"
                    name="WSHttpBinding_IWCFService" />
            </client>
        </system.serviceModel>

  • 相关阅读:
    叶落归根(hometown)
    设置(settings)
    文明距离(civil)
    计算机基础知识
    gojs插件使用教程
    编程语言分类
    dp优化简单总结
    Splay入门题目 [HNOI2002]营业额统计
    hdu3415:最大k子段和,单调队列
    hdu5072(鞍山regional problem C):容斥,同色三角形模型
  • 原文地址:https://www.cnblogs.com/zmc/p/2434624.html
Copyright © 2011-2022 走看看