wcf - 使用 netTcpBinding 在 IIS 7.0 中托管 WCF 服务到底需要做什么?

标签 wcf iis-7 nettcpbinding

我已经尝试了一个多星期没有任何成功,使用 netTcpBinding 托管一个非常简单的类似 HelloWorld 的 wcf 服务。

使用http,一切正常。我什至可以从远程机器访问我的服务。但是随着tcp问题出现了。

为了在 WAS 中托管我的服务,我已经执行了所有我应该执行的步骤:

  • .Net 3.0 功能已启用,包括 http 和非 http 激活
  • 我已授予“网络服务”和“IIS_IUSRS”对包含该站点的文件夹的以下权限:
  • 阅读并执行
  • 列出文件夹内容
  • 阅读
  • 在防火墙中打开了 de 端口 8100 和 8086。
  • 在 IIS 管理器/操作/绑定(bind)中设置了以下绑定(bind):
  • http 8100:*
  • net.tcp 8086:*
  • 在 IIS 管理器/管理网站/高级设置中,http 和 net.tcp 协议(protocol)均已启用。

  • 我最初遇到的问题是我能够通过 http 访问该服务,但是在尝试使用 tcp 时出现以下错误:

    “无法发送消息,因为端点地址‘net.tcp://myDomain/HelloWorld.Hello.svc’的服务对协议(protocol)地址不可用。

    我在这个网站上发现了一个帖子,作者有同样的问题,通过重新安装 .net 3.0 功能解决了。所以我试了一下。为了以防万一,我还尝试重新安装 IIS 7.0。
    现在,情况比开始时还要糟糕。如果我在我的 Web.Config 中使用 tcpBinding 配置一个端点,我什至无法使用 IE 在它的 http 地址访问我的服务!我收到以下消息:

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

    Web.Config 文件如下:








           name="HelloWorld.Hello">
           <host>
              <baseAddresses>
                 <add baseAddress="http://myDomain:8100/HelloWorld/" />
             <add baseAddress="net.tcp://myDomain:8086/HelloWorld/" />
              </baseAddresses>
           </host>          
    
           <endpoint address=""
                     binding="wsHttpBinding"
                     contract="HelloWorld.IHello"
                     bindingConfiguration="httpInseguro">
           </endpoint>
    
           <endpoint address=""
                     binding="netTcpBinding"
                     contract="HelloWorld.IHello"
                     bindingConfiguration="netTcpInseguro">
           </endpoint>
    
    
           <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
    
        </service>
     </services>
    
    <bindings>
    
      <wsHttpBinding>
        <binding name ="httpInseguro">
          <security mode ="None" />
        </binding>        
      </wsHttpBinding>
    
      <netTcpBinding>
        <binding name ="netTcpInseguro">
          <security mode ="None" />
        </binding>        
      </netTcpBinding>
    
    </bindings>
    

    .svc 文件是这样的:

    谁能给我一个关于发生了什么的线索?我真的不知道还能做什么。这是一个真正令人头疼的问题,因为使用 http 绑定(bind)不是一种选择。
    提前致谢。

    最佳答案

    您需要通过调用 appcmd.exe 在 WAS 中启用 TCP 托管。 :

    %windir%\system32\inetsrv\appcmd.exe set site 
        "Default Web Site" -+bindings.[protocol='net.tcp',bindingInformation='*']
    

    查看 MSDN documenation或 Michele Leroux Bustamante 的 article on this topic - 它包含您需要的所有信息。

    马克

    关于wcf - 使用 netTcpBinding 在 IIS 7.0 中托管 WCF 服务到底需要做什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1105788/

    相关文章:

    wcf - SOA 服务测试

    wcf - 根据配置更新服务引用地址?

    iis-7 - IIS URL 重写 - 友好 URL : Querystring variable is repeated

    .net - 设置每个操作的 MaxAllowedContentLength/maxRequestLength 值

    c# - WCF 每秒无法处理 1000 个调用

    .net - 如何找到 NetTcpBinding (WCF) 可用的 TCP 端口(以便服务器可以绑定(bind)到它)

    .net - WCF 和 NetTcp 绑定(bind)

    c# - 如何使用 WCF 流式传输 XElement/XDocument?

    git - 如何在 IIS 上设置 Git 裸 HTTP 可用存储库

    wcf - 抛出 CommunicationObjectAbortedException 后恢复回调 channel