c# - 使用 net.tcp 绑定(bind)在 IIS 7 上托管 WCF 服务 - 使用服务时出错

标签 c# wcf iis-7 was net.tcp

我正在尝试在 IIS 7/Win 7 中托管具有 Net TCP 绑定(bind)的 WCF 服务。该服务已托管,我可以在客户端应用程序中添加对其的引用。

这是服务配置文件:

  <configuration>

    <system.web>
      <compilation debug="true" targetFramework="4.0" />

    </system.web>
    <system.serviceModel>
      <bindings>
        <netTcpBinding>
          <binding name="InsecureTcp" portSharingEnabled ="true">
            <security mode="None">
              <transport clientCredentialType="None" protectionLevel="None" />
            </security>
          </binding>
        </netTcpBinding>
      </bindings>
      <services>
        <service name="ApplicationProcessService">
          <endpoint address="" binding="netTcpBinding" bindingConfiguration="InsecureTcp"
            name="NetTCP_Port10000" contract="IApplicationProcess" />
          <endpoint address="mex" binding="mexHttpBinding" name="mexNetTCP_Port10000"
            contract="IMetadataExchange" />
        </service>
      </services>
      <behaviors>
        <serviceBehaviors>
          <behavior name="">
            <serviceMetadata httpGetEnabled="true" />
            <serviceDebug includeExceptionDetailInFaults="true" />
          </behavior>
        </serviceBehaviors>
      </behaviors>
      <serviceHostingEnvironment multipleSiteBindingsEnabled="true">
        <baseAddressPrefixFilters>
        </baseAddressPrefixFilters>
      </serviceHostingEnvironment>

    </system.serviceModel>
    <system.webServer>
      <modules runAllManagedModulesForAllRequests="true"/>
    </system.webServer>

  </configuration>

这是我添加引用时在客户端生成的配置:

<configuration>
  <system.serviceModel>
    <bindings>
      <netTcpBinding>
        <binding name="NetTCP_Port10000" closeTimeout="00:01:00" openTimeout="00:01:00"
            receiveTimeout="00:10:00" sendTimeout="00:01:00" transactionFlow="false"
            transferMode="Buffered" transactionProtocol="OleTransactions"
            hostNameComparisonMode="StrongWildcard" listenBacklog="10"
            maxBufferPoolSize="524288" maxBufferSize="65536" maxConnections="10"
            maxReceivedMessageSize="65536">
          <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
              maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          <reliableSession ordered="true" inactivityTimeout="00:10:00"
              enabled="false" />
          <security mode="None">
            <transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
            <message clientCredentialType="Windows" />
          </security>
        </binding>
      </netTcpBinding>
    </bindings>
    <client>
      <endpoint address="net.tcp://localhost:10000/ApplicationProcess.svc"
          binding="netTcpBinding" bindingConfiguration="NetTCP_Port10000"
          contract="ApplicationProcessService.IApplicationProcess" name="NetTCP_Port10000" />
    </client>
  </system.serviceModel>
</configuration>

问题是在运行时,我收到以下错误:-

Could not connect to net.tcp://localhost:10000/AppServer.ApplicationProcess.svc. The connection attempt lasted for a time span of 00:00:02.0582058. TCP error code 10061: No connection could be made because the target machine actively refused it.

我已按照http://www.singingeels.com/Articles/Duplex_WCF_Services_Hosted_in_IIS_Using_NetTcp.aspx中描述的步骤进行操作

并在我的防火墙中创建了一条入站规则,允许在端口 10000 上进行 TCP 通信。我不确定我错过了什么。有什么想法吗?

最佳答案

这里的关键是您已启用端口共享(绑定(bind)中的 PortSharingEnabled),这要求您运行 TCP 端口共享服务,该服务默认情况下在 Windows 中不运行。请参阅此链接:NetTcpBinding.PortSharingEnabled

关于c# - 使用 net.tcp 绑定(bind)在 IIS 7 上托管 WCF 服务 - 使用服务时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7019233/

相关文章:

windows - 在 Windows 7 中从 IIS 7.0 升级到 IIS 7.5

背景面板的 C# 鼠标悬停事件

c# - ClientMessageInspector 添加 BinarySecurityToken 和签名

asp.net-mvc - 将 asp.net mvc 5 部署到 iis 服务器时出现问题

wcf - 将服务引用添加到 Windows 服务中托管的 WCF 服务时出现问题

c# - 如何在 C# 中通过名称查找位置的纬度和经度?

.net - 无法在IIS 7.5上使用Enable32Mode加载32位dll

c# - Entity Framework 是否支持 Oracle 同义词?

c# - 如何使用 EntityFramework 实现通用 MVC Web Controller 和用于 CRUD 操作的通用 View

c# - 如何使用存储过程在 LINQ to SQL 中使用事务?