0

我正在尝试在 64 位 Windows 7 上的 IIS 7.5 站点中托管具有 net.tcp 绑定的 WCF 服务。可悲的是,该服务无法访问。事实上,使用 telnet 打开与 TCP 端口的连接甚至会失败。

这是我的网站 web.config 的 system.serviceModel 部分的样子:

<system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior name="DefaultServiceBehavior">
          <serviceMetadata httpGetEnabled="false" />
          <serviceDebug includeExceptionDetailInFaults="true" />
          <dataContractSerializer maxItemsInObjectGraph="2000000" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <services>
      <service behaviorConfiguration="DefaultServiceBehavior" 
               name="FooService">
        <endpoint binding="netTcpBinding" bindingConfiguration="service" 
                  name="service" contract="IFoo" />
        <endpoint binding="mexTcpBinding" 
                  bindingConfiguration="DuplexBinding" contract="IFoo" />
        <host>
          <baseAddresses>
            <add baseAddress="net.tcp://127.0.0.1:9000/service"/>
          </baseAddresses>
        </host>
      </service>
    </services>
    <bindings>
      <netTcpBinding>
        <binding name="service" portSharingEnabled="true">
          <readerQuotas maxDepth="32" maxStringContentLength="8192" 
                        maxArrayLength="16384" maxBytesPerRead="4096" 
                        maxNameTableCharCount="16384" />
          <security mode="None"/>
        </binding>
        <binding name="DuplexBinding">
          <reliableSession enabled="true"/>
          <security mode="None"/>
        </binding>
      </netTcpBinding>
    </bindings>
</system.serviceModel>

在 IIS 管理器中,我设置了一个站点,其中包含一个以 NETWORK SERVICE 身份运行的应用程序池,具有 v4.0 .NET Framework 和集成管道。该站点有一个绑定类型,net.tcp“绑定信息”设置为9000:*

在我电脑的服务下,我启动了之前停止的“Net.Tcp Listener Adapter”和“Net.Tcp Port Sharing Service”服务,并让它们都自动启动。我还确保安装了“Windows Communication Foundation Non-HTTP Activation”。

我还需要做什么才能让 IIS/WCF/WAS/whatever 监听端口 9000,以便激活和调用我的服务?

我的问题类似于Host WCF service with net.tcp binding through IIS Manager 7.5,但是 OP 没有注册,他的问题也没有得到回答。我打开这个问题,所以我可以发布我自己的详细信息。

更新

我发现了一些额外的线索。我决定添加第二个绑定,以便在尝试找出 net.tcp 问题的同时使用 HTTP 绑定。现在,当我尝试访问 HTTP 端点时,我收到了这个错误

找不到与具有绑定 NetTcpBinding 的终结点的方案 net.tcp 匹配的基地址。注册的基地址方案是 [http]

我很清楚这里HTTP 和 net.tcp 的绑定:

<baseAddresses>
    <add baseAddress="net.tcp://localhost:9000/"/>
    <add baseAddress="http://localhost:8050/"/>
</baseAddresses>

所以“注册基地址方案”这句话让我很担心;为了让我的站点支持 net.tcp 方案,我还需要做些什么吗?

4

4 回答 4

1

我终于让 IIS 允许连接到端口 9000。我之前没有看到这个选项,但我不知道这是因为我的抽查失败还是我必须做一些事情才能让它显示出来。

在 IIS 站点的高级设置下,有一个“启用的协议”设置。以前,它被设置为http. 将其更改为 后http, net.tcp,我可以连接到 TCP 端口。

于 2011-11-11T17:13:31.120 回答
0

看起来你已经正确地完成了大多数事情。

剩下的最可能的问题是防火墙。标准的 Windows 防火墙阻止了端口 9000。

于 2011-11-09T19:40:31.250 回答
0

我会尝试 SSamra 的建议。我认为您的基址和您尝试的 URL 可能是错误的。我的看起来像这样:

net.tcp://localhost:PORT/ServiceNamespace/ClassName。

于 2011-11-11T14:55:23.613 回答
0

由于您使用的是 IIS,因此我将完全删除baseAddress节点,因为 IIS 将从您配置的绑定/虚拟路径中推断出基地址。

还要记住,httpGetEnabled="true"如果没有任何可用的 http 端点,WCF 不会对元数据行为中的属性感到满意。

于 2012-02-27T21:17:50.693 回答