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>

  • 相关阅读:
    HTTP报文(转)
    批处理增加开机启动项(转)
    HTTP代理服务程序介绍(copy)
    MP3文件格式说明 (转)
    [sql] SQL Server判断对象是否存在
    MSSQL 链接远程数据库 读取并操作数据
    将无线网卡变成“无线路由器(无线AP)”
    :DOS命令大全(经典收藏)
    java 使用 poi 操纵 excel2003 经验总结
    log4j.properties的配置详解(根据网络资料整理)
  • 原文地址:https://www.cnblogs.com/zmc/p/2434624.html
Copyright © 2011-2022 走看看