您的位置:首页 > 其它

如何配置不启用安全的WCF服务

2012-04-06 14:23 691 查看
[转]如何配置不启用安全的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>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐