[WCF]NetTcpBinding在IIS中使用的详细配置方法
在WCF的配置过程中,常常会遇到各种各样的错误。
如:找不到具有绑定 NetTcpBinding 的终结点的与方案 net.tcp 匹配的基址。注册的基址方案是 。
网络上存在各种各样的方法,但很少有能够全面解决的。
现举例来配置NetTcpBinding的方法:
首先尽量要保证你的配置文件是正确的,如:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="ShuiMoNet_Service.FileOperation.binding" closeTimeout="00:30:00"
openTimeout="00:30:00" receiveTimeout="00:30:00" sendTimeout="00:30:00"
transactionFlow="false" transferMode="Streamed" transactionProtocol="OleTransactions"
hostNameComparisonMode="StrongWildcard" listenBacklog="10"
maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxConnections="10"
maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="2147483647"maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<reliableSession ordered="true"inactivityTimeout="00:01:00" enabled="false" />
<security mode="None">
<transport clientCredentialType="Windows" protectionLevel="EncryptAndSign"></transport>
<message clientCredentialType="Windows" />
</security>
</binding>
</netTcpBinding>
</bindings>
<services>
<service name="ShuiMoNet_Service.FileOperation" behaviorConfiguration="ShuiMoNet_Service.FileOperation.Behavior">
<endpoint binding="netTcpBinding"bindingConfiguration="ShuiMoNet_Service.FileOperation.binding" contract="ShuiMoNet_Service.IFileOperation" address="FileOperation"></endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:8001/"/>
<add baseAddress="http://localhost:8002/"/>
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ShuiMoNet_Service.FileOperation.Behavior">
<serviceMetadata httpGetEnabled="false"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
<dataContractSerializer maxItemsInObjectGraph="6553600"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
配置,基本上如上已经够全面了。
其次,我们首先应该检查你是否启用了WCF功能:
接着检查是否在IIS中启用了net.tcp协议:
最后我们应该在站点绑定中如下配置net.tcp路由:
这样我们的NetTcpBinding协议就受到支持了。如上Bug也已经解决。
更多WEB开发技术请加群:Asp.Net高级群 号码:261882616
博主以及同事和你共同探讨感兴趣的话题。
页:
[1]