我正在尝试在 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 方案,我还需要做些什么吗?