在iis7上托管WCF服务.tcp绑定-使用服务时出错

本文关键字:服务 出错 绑定 tcp WCF iis7 | 更新日期: 2023-09-27 18:05:26

我正在尝试在IIS 7/win7中托管具有Net TCP绑定的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>

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

无法连接到net.tcp://localhost:10000/AppServer.ApplicationProcess.svc。连接尝试持续的时间跨度为00:00:02. 582058。TCP错误码10061:没有连接可以建立,因为目标机器主动拒绝它。

我遵循了http://www.singingeels.com/Articles/Duplex_WCF_Services_Hosted_in_IIS_Using_NetTcp.aspx

中描述的步骤

并在防火墙中创建了一个入站规则,允许在端口10000上进行TCP通信。我不知道我错过了什么。任何想法吗?

在iis7上托管WCF服务.tcp绑定-使用服务时出错

这里的关键是您已经启用了端口共享(PortSharingEnabled在您的绑定中),这需要您运行TCP端口共享服务,该服务在Windows中默认不运行。请看这个链接:netttcpbinding。PortSharingEnabled

除网。前面提到的Tcp端口共享服务,您还需要启用并启动Net。

除了需要启用的服务之外,我还必须启用IIS来识别net.tcp。右键单击您的网站>管理应用程序>高级设置。"已启用协议"的值应该是:http,net.tcp