我尝试使用net.tcp绑定设置测试服务。我还设置了一个http端点。配置如下:
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="Inbound_REST">
<webHttp />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="InboundHttpConfiguration">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
<behavior name="InboundTcpConfiguration">
<serviceMetadata httpGetEnabled="false" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="InboundTcpConfiguration" name="Inbound">
<endpoint address="" binding="netTcpBinding" contract="IContract">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:6969/Inbound" />
</baseAddresses>
</host>
</service>
</services>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
<client>
<endpoint name="httpEndPoint" address="http://localhost:1568/Inbound.svc" binding="basicHttpBinding" contract="IContract" />
<endpoint name="tcpEndPoint" address="net.tcp://localhost:6969/Inbound" binding="netTcpBinding" contract="IContract" />
</client>
<bindings>
<basicHttpBinding>
<binding name="httpbind">
<security mode="Transport">
<transport clientCredentialType="None"/>
</security>
</binding>
</basicHttpBinding>
<netTcpBinding>
<binding name="tcpbind">
<security mode="Transport">
<transport clientCredentialType="None" />
</security>
</binding>
</netTcpBinding>
</bindings>
</system.serviceModel>
当我尝试使用net.tcp绑定使用服务时,它总是返回错误:
无法连接到net.tcp:// localhost:6969 / Inbound。连接尝试持续时间跨度为00:00:00.9531494。 TCP错误代码10061:无法建立连接,因为目标计算机主动拒绝它127.0.0.1:6969。
顺便说一句,http绑定工作正常。我认为这可能是一些机器配置,但无法找到根本原因。
答案 0 :(得分:3)
如果您尝试通过visual studio运行WCF服务,则不支持netTcpBinding。遗憾!
答案 1 :(得分:0)
为什么要省略客户端net.tcp地址的“.svc”?也许它应该是“net.tcp:// localhost:6969 / Inbound.svc”
答案 2 :(得分:0)
你正在使用什么托管..IIS7或控制台或其他?
1)检查所有tcp服务是否在services.msc
中运行2)关闭防火墙或将防火墙例外添加到您的tcp端口
如果您在iis7中托管,请查看此链接