案例下载

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的更多相关文章

  1. WCF学习之旅—WCF服务的Windows 服务程序寄宿(十一)

    上接    WCF学习之旅—WCF服务部署到IIS7.5(九) WCF学习之旅—WCF服务部署到应用程序(十) 七 WCF服务的Windows 服务程序寄宿 这种方式的服务寄宿,和IIS一样有一个一样 ...

  2. WCF寄宿到Windows Service

    WCF寄宿到Windows Service[1] 2014-06-14 WCF寄宿到Windows Service参考 WCF寄宿到Windows Service 返回 在前面创建一个简单的WCF程序 ...

  3. WCF寄宿到Windows Service[1]

    WCF寄宿到Windows Service 返回 在前面创建一个简单的WCF程序,我们把WCF的服务寄宿到了Host这个控制台项目中了.下面将介绍如何把WCF的服务寄宿到Windows服务中(源代码) ...

  4. WCF 部署在Windows 2012 IIS上各种报错的解决方法

    1.由于扩展配置问题而无法提供您请求的页面.如果该页面是脚本 ,请添加处理程序.如果勇载文件,请添加 MIME 映射. 以管理员身份,在cmd中运行C:\Windows\Microsoft.NET\F ...

  5. WCF 下的windows服务的安装卸载

    安装:启动vs2010(如果是win2008要以管理员来启动)命令:installutil demo.exe 卸载:先在服务里停止这个服务,然后启动vs2010(如果是win2008要以管理员来启动) ...

  6. WCF服务寄宿Windows

    windows服务的介绍 Windows服务应用程序是一种需要长期运行的应用程序,它对于服务器环境特别适合.它没有用户界面,并且也不会产生任何可视输出.任何用户消息都会被写进Windows事件日志.计 ...

  7. 使用C#创建及调用WCF完整实例 (Windows服务宿主)

    关于WCF的概念.原理.优缺点等,在这里就不多说了,网上很多,可以自行搜索,比我解释的要专业的多. 这里直接说使用Windows 服务(Windows Service)作为宿主如何实现,其它方式不在此 ...

  8. WCF 安全性之 自定义用户名密码验证

    案例下载 http://download.csdn.net/detail/woxpp/4113172 客户端调用代码 通过代理类 代理生成 参见 http://www.cnblogs.com/woxp ...

  9. WCF 安全性 之 自定义证书验证

    案例下载 http://download.csdn.net/detail/woxpp/4113172 客户端调用代码 通过代理类 代理生成 参见 http://www.cnblogs.com/woxp ...

随机推荐

  1. 《DSP using MATLAB》第6章开始了

    看到第6章了,标记一下,全书近一半,继续加油 构建滤波器的三种元件: 下面是函数floor和size的部分帮助截图

  2. ASP.NET MVC3中Controller与View之间的数据传递总结

    一.  Controller向View传递数据 1.       使用ViewData传递数据 我们在Controller中定义如下: ViewData["Message_ViewData& ...

  3. homebrew update 出现Failure while executing: git pull --quiet origin refs/heads/master:refs/remotes/origin/master解决方案

    具体可以参考https://github.com/Homebrew/homebrew/issues/21002 cd /usr/local git status git reset --hard or ...

  4. PyCharm 代码完成/代码提示

    因为python是动态语言,所以在有些情况ide会无法有效代码提示,见下: import sqlite3 conn = sqlite3.connect('d:/xxx.db') conn.  #这里按 ...

  5. 运行jar应用程序引用其他jar包的四种方法

    转载地址:http://www.iteye.com/topic/332580 大家都知道一个java应用项目可以打包成一个jar,当然你必须指定一个拥有main函数的main class作为你这个ja ...

  6. JNI和NDK编程

    Java JNI的本意是Java Native Interface(Java本地接口),它是为了方便Java调用C.C++等本地代码所封装的一层接口.通过Java JNI,用户可以调用C.C++所编写 ...

  7. python lxml install

    之前记得安装libxslt和libxml yum install libxml* -yyum install libxslt* -y wget http://lxml.de/files/lxml-3. ...

  8. Mac系统中配置Tomcat环境

    第一步:下载Tomcat 下载地址:http://tomcat.apache.org/download-80.cgi 直接下载如图选中的即可 第二步: 下载完成后,解压,随意放入目录.如我就把它放在/ ...

  9. script async 和script defer的区别

    浏览器对js文件的操作主要有两部分:下载和执行: js文件下载在有些浏览器中是并行的,在有些浏览器中是串行的,如:IE8.firefox3.chrome2都是串行下载的: 执行在所有浏览器中默认是阻塞 ...

  10. Java反编译代码对齐

    使用反编译的代码作为jar包源码进行调试时,经常会遇到的情况是反编译后的源码之在注释里包含行号,但是与代码所在行经常对应不上.这个时候,就有必要对代码进行对齐了. ​ public class Reo ...