让IIS支持WCF的netTcpBinding
来源:互联网 发布:数据分析职称 编辑:程序博客网 时间:2024/05/19 08:02
使用WCF的时间不是很长,但是感觉他博大精深,将网络通信的复杂完全隐藏在一个配置文件和接口中。
因为我搞过SOCKET通信模块的编写,对此深有体会!
问题来源,IIS原生支持HTTP协议,不需要做过多的配置就能够让使用这个协议的WCF接口工作,具体协议为basicHttpBinding,wsHttpBinding。但是在测试的过程当中发现netTcpBinding协议的传输速度是basicHttpBinding的三倍以上,所以想使用netTcpBinding协议作为WCF接口的数据传输途径。
但是要让IIS支持WCF的netTcpBinding比较费力,在研究了数天之后总算得到了解决方案。
Web.config具体配置如下:
<?xml version="1.0"?><configuration> <system.web> <compilation debug="true" targetFramework="4.0"/> <pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID"/> </system.web> <system.serviceModel> <behaviors> <serviceBehaviors> <behavior name="TempBehavior"> <!-- 为避免泄漏元数据信息,请在部署前将以下值设置为 false 并删除上面的元数据终结点 --> <serviceMetadata httpGetEnabled="true"/> <!-- 要接收故障异常详细信息以进行调试,请将以下值设置为 true。在部署前设置为 false 以避免泄漏异常信息 --> <serviceDebug includeExceptionDetailInFaults="false"/> <!--设置连接数量--> <serviceThrottling maxConcurrentCalls="2147483647" maxConcurrentInstances="2147483647" maxConcurrentSessions="2147483647"/> <!--安全验证--> <!--<serviceCredentials> <clientCertificate> <authentication certificateValidationMode="None"/> </clientCertificate> </serviceCredentials>--> </behavior> </serviceBehaviors> </behaviors> <!--接收数据大小,加密设置:transport,默认安全级别为加密和完整性验证--> <bindings> <netTcpBinding> <binding name="TempNetTcpBinding" maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647"> <security mode="None"> <transport clientCredentialType="Windows" protectionLevel="None"/> <message clientCredentialType="Windows"/> </security> </binding> </netTcpBinding> <!--<wsHttpBinding> <binding name="TempWsHttpBinding" maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647"> <security mode="None"> <transport clientCredentialType="Windows"/> <message clientCredentialType="Windows"/> </security> </binding> </wsHttpBinding>--> </bindings> <serviceHostingEnvironment multipleSiteBindingsEnabled="true"/> <services> <service behaviorConfiguration="TempBehavior" name="TempWcf.Server.ServiceTemp"> <endpoint address="" binding="netTcpBinding" bindingConfiguration="TempNetTcpBinding" contract="TempWcf.Server.IServiceTemp"/> <endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange"/> </service> <!--<service behaviorConfiguration="TempBehavior" name="TempWcf.Server.ServiceTemp"> <endpoint address="" binding="wsHttpBinding" bindingConfiguration="TempWsHttpBinding" contract="TempWcf.Server.IServiceTemp" /> </service>--> </services> </system.serviceModel> <system.webServer> <modules runAllManagedModulesForAllRequests="true"/> </system.webServer></configuration>
上图就是我的配置文件,关键代码有两处,一处是:
<services> <service behaviorConfiguration="TempBehavior" name="TempWcf.Server.ServiceTemp"> <endpoint address="" binding="netTcpBinding" bindingConfiguration="TempNetTcpBinding" contract="TempWcf.Server.IServiceTemp"/> <endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange"/> </service>
上面的代码规定了IIS配置使用NET.TCP协议;
另外一处是:
<security mode="None"> <transport clientCredentialType="Windows" protectionLevel="None"/> <message clientCredentialType="Windows"/> </security>
上面的代码是安全协议;
上面两处中任何一处配置不对都会导致netTcpBinding协议不能正确运行。
其二,需要配置IIS支持net.tcp协议
具体设置如下:
经过以上两步的配置,就可以让IIS支持WCF的netTcpBinding了。
阅读全文
0 0
- 让IIS支持WCF的netTcpBinding
- [WCF]NetTcpBinding在IIS中使用的详细配置方法
- WCF绑定netTcpBinding寄宿到IIS
- WCF netTcpBinding:如何将net.tcp协议寄宿到IIS
- 启用WCF NetTcpBinding的共享端口
- WCF采用 netTcpBinding 发生的Socket errors
- IIS添加WCF支持
- WCF中netTcpBinding使用
- 让Server 2000的IIS支持中文
- 让你的IIS服务器支持JSP
- 让IIS支持FLEX的MXML格式
- 让IIS支持PHP的配置方法
- 如何让自己的IIS支持Silverlight
- 让你的IIS服务器支持JSP
- 让IIS支持.apk文件的下载
- 让你的IIS服务器支持JSP
- 稳扎稳打Silverlight(53) - 4.0通信之对WCF NetTcpBinding的支持, 在Socket通信中通过HTTP检索策略文件, HTTP请求中的ClientHttp和Browse
- 稳扎稳打Silverlight(53) - 4.0通信之对WCF NetTcpBinding的支持, 在Socket通信中通过HTTP检索策略文件, HTTP请求中的ClientHttp和Browse
- Android NumberPicker滚动字符串
- 第2周项目1-C/C++语言中函数参数传递的三种方式
- Logstash的性能测试 二
- OPENCL:从朴素到更具深度的编程(转载)
- iOS苹方字体使用说明
- 让IIS支持WCF的netTcpBinding
- servlet的url-pattern匹配规则详细描述
- 关于守护进程linuxc
- 大型网站技术架构
- logstash性能测试
- scrapy学习笔记
- LARC DL笔记(六):Saliency Map
- 虚线
- CONTROL OUT transfer failed with Error Code:997