WCF 安全性 之 Windows
案例下载
http://download.csdn.net/detail/woxpp/4113172
服务端配置代码
<system.serviceModel>
<services>
<service name="WcfServiceLibrary.ServiceTcp">
<endpoint address="net.tcp://localhost:8731/WcfServiceLibrary"
binding="netTcpBinding" bindingConfiguration="testnetTcpBinding"
contract="WcfServiceLibrary.IService1">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8732/WcfServiceLibrary" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- 为避免泄漏元数据信息,
请在部署前将以下值设置为 false 并删除上面的元数据终结点 -->
<serviceMetadata httpGetEnabled="True"/>
<!-- 要接收故障异常详细信息以进行调试,
请将以下值设置为 true。在部署前设置为 false
以避免泄漏异常信息-->
<serviceDebug includeExceptionDetailInFaults="False" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<netTcpBinding>
<binding name="testnetTcpBinding">
<security mode="Message">
<transport clientCredentialType="None" protectionLevel="None"></transport>
<message clientCredentialType="Windows"/>
</security>
</binding>
</netTcpBinding>
</bindings>
</system.serviceModel>
客户端调用代码 通过代理类
http://www.cnblogs.com/woxpp/p/6232298.html
客户端代码
//获取域名
String hostName = Dns.GetHostName();
IPHostEntry ipH = new IPHostEntry();
ipH = Dns.Resolve(hostName);
NetTcpBinding netTcp = new NetTcpBinding();
netTcp.Security.Mode = SecurityMode.Message;
netTcp.Security.Transport.ProtectionLevel = ProtectionLevel.None;
netTcp.Security.Transport.ClientCredentialType = TcpClientCredentialType.None;
netTcp.Security.Message.ClientCredentialType = MessageCredentialType.Windows;
ChannelFactory<IService1> factory = new ChannelFactory<IService1>(netTcp);
factory.Credentials.Windows.ClientCredential.UserName = "panpan.xu";
factory.Credentials.Windows.ClientCredential.Password = "123.xpp";
factory.Credentials.Windows.ClientCredential.Domain = "panpanxu-PC";
IService1 proxy = factory.CreateChannel(new EndpointAddress("net.tcp://localhost:8731/WcfServiceLibrary"));
txtMessage.Text = proxy.GetDataUsingDataContract(new WcfServiceLibrary.CompositeType() { StringValue = "sssss" }).StringValue;
WCF 安全性 之 Windows的更多相关文章
- WCF学习之旅—WCF服务的Windows 服务程序寄宿(十一)
上接 WCF学习之旅—WCF服务部署到IIS7.5(九) WCF学习之旅—WCF服务部署到应用程序(十) 七 WCF服务的Windows 服务程序寄宿 这种方式的服务寄宿,和IIS一样有一个一样 ...
- WCF寄宿到Windows Service
WCF寄宿到Windows Service[1] 2014-06-14 WCF寄宿到Windows Service参考 WCF寄宿到Windows Service 返回 在前面创建一个简单的WCF程序 ...
- WCF寄宿到Windows Service[1]
WCF寄宿到Windows Service 返回 在前面创建一个简单的WCF程序,我们把WCF的服务寄宿到了Host这个控制台项目中了.下面将介绍如何把WCF的服务寄宿到Windows服务中(源代码) ...
- WCF 部署在Windows 2012 IIS上各种报错的解决方法
1.由于扩展配置问题而无法提供您请求的页面.如果该页面是脚本 ,请添加处理程序.如果勇载文件,请添加 MIME 映射. 以管理员身份,在cmd中运行C:\Windows\Microsoft.NET\F ...
- WCF 下的windows服务的安装卸载
安装:启动vs2010(如果是win2008要以管理员来启动)命令:installutil demo.exe 卸载:先在服务里停止这个服务,然后启动vs2010(如果是win2008要以管理员来启动) ...
- WCF服务寄宿Windows
windows服务的介绍 Windows服务应用程序是一种需要长期运行的应用程序,它对于服务器环境特别适合.它没有用户界面,并且也不会产生任何可视输出.任何用户消息都会被写进Windows事件日志.计 ...
- 使用C#创建及调用WCF完整实例 (Windows服务宿主)
关于WCF的概念.原理.优缺点等,在这里就不多说了,网上很多,可以自行搜索,比我解释的要专业的多. 这里直接说使用Windows 服务(Windows Service)作为宿主如何实现,其它方式不在此 ...
- WCF 安全性之 自定义用户名密码验证
案例下载 http://download.csdn.net/detail/woxpp/4113172 客户端调用代码 通过代理类 代理生成 参见 http://www.cnblogs.com/woxp ...
- WCF 安全性 之 自定义证书验证
案例下载 http://download.csdn.net/detail/woxpp/4113172 客户端调用代码 通过代理类 代理生成 参见 http://www.cnblogs.com/woxp ...
随机推荐
- java后台获取Access_token的工具方法
本方法主要通过java后台控制来获取Access_token,需要你已经知道自己的ID跟密码 因为微信的权限设置大概每天可以获取两千条,每条有效时间为2小时 /** * 输入自己的id跟密码,获取微信 ...
- css/js(工作中遇到的问题)-4
JS生成随机的由字母数字组合的字符串 Math.random().toString(36).substr(2)
- 批发零售车销门店扫描打印一体移动销售POS机-移动终端销售O2O新模式
应用领域 终端及移动解决方案 方案概述 通过手持终端对数据进行采集并分析及汇总.利用WIFI网络和专用终端,实时上报终端的各种销量数据,如订单数据.销量数据.库存数据.补货数据.调货数据等. 业务价值 ...
- 车销宝无线开单PDA 一款互联网+POS神器 无缝与电脑数据同步 无线POS开单解决方案
1.无线POS开单解决方案是基于后台系统开发的一套系统,它实现了采购入库退货.销售出库退货.盘点调拨等功能. 2.系统通过(WIFI.GPRS.GSM.蓝牙)实时后台库存.客户.商品.价格跟踪等信息, ...
- git本地有修改如何强制更新
本地有修改和提交,如何强制用远程的库更新更新.我尝试过用git pull -f,总是提示 You have not concluded your merge. (MERGE_HEAD exists). ...
- BZOJ 2342 & manachar+最优性剪枝
题意: 求最长回文串,串的两边都是回文串. Solution: manachar预处理然后暴力找... Code: #include <iostream> #include <cst ...
- CentOS搭建SVN记录
1.安装subversion(client and server) $ yum install subversion $ yum install mod_dav_svn 安装成功之后使用 svnser ...
- Difference between WCF and Web API and WCF REST and Web Service
The .Net framework has a number of technologies that allow you to create HTTP services such as Web S ...
- Apache InterfaceAudience
InterfaceAudience 类包含三个注解类型,用来被说明被他们注解的类型的潜在的使用范围(audience).@InterfaceAudience.Public: 对所有工程和应用可用@In ...
- CF2.BC
B. Arpa's obvious problem and Mehrdad's terrible solution time limit per test 1 second memory limit ...