WCF问题(10):如何配置不启用安全的WCF服务?
-
2010年12月2日 5:08版主
WCF问题(10):如何配置不启用安全的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>-------------------------------------------------------------------------------- 【老徐的博客】 【作 者】:Frank Xu Lei 【网 站】:http://www.frankxulei.com/ 【中文论坛】:微软WCF中文技术论坛 【英文论坛】:微软WCF英文技术论坛
Frank Xu Lei--谦卑若愚,好学若饥
专注于.NET平台下分布式应用系统开发和企业应用系统集成
Focus on Distributed Applications Development and EAI based on .NET
【老徐的网站】:http://www.frankxulei.com/
微软WCF中文技术论坛
微软WCF英文技术论坛
Windows Azure中文技术论坛
- 已编辑 Frank Xu LeiMVP, Moderator 2010年12月2日 5:10 代码
全部回复
-
2010年12月2日 5:09版主WCF问题(10):如何配置不启用安全的WCF服务?
Frank Xu Lei--谦卑若愚,好学若饥
专注于.NET平台下分布式应用系统开发和企业应用系统集成
Focus on Distributed Applications Development and EAI based on .NET
【老徐的网站】:http://www.frankxulei.com/
-
2010年12月2日 5:21版主
仅供参考
Frank Xu Lei--谦卑若愚,好学若饥
专注于.NET平台下分布式应用系统开发和企业应用系统集成
Focus on Distributed Applications Development and EAI based on .NET
【老徐的网站】:http://www.frankxulei.com/
-
2010年12月3日 12:08你好,如果采用<security mode="Message">应该怎么配置呢?
-
2010年12月4日 8:53版主看看这个 http://www.frankxulei.com/?cat=9
Frank Xu Lei--谦卑若愚,好学若饥
专注于.NET平台下分布式应用系统开发和企业应用系统集成
Focus on Distributed Applications Development and EAI based on .NET
【老徐的网站】:http://www.frankxulei.com/