【发布时间】:2015-03-06 18:11:12
【问题描述】:
我有 WCF 和 net.tcp 绑定的常见问题。 我也看到 stackoverflow 上的所有帖子也在谷歌上搜索..
我无法向客户端添加服务引用的主要问题。 我得到错误:
Could not find a base address that matches scheme net.tcp for the endpoint with binding NetTcpBinding. Registered base address schemes are [http].
-
我使用的是 IIS 7。我检查了非 HTTP。我在启用协议 net.tcp 中添加到网站,还将 net.tcp 添加到绑定中。如果我点击浏览(http)我的地址。我看到我的文件夹带有 WCF 应用程序,如果我选择 svc 文件,我会看到正常地址:
svcutil.exe net.tcp://MYADDRESS/Service.svc/mex
如果我看到这个 URL,我猜我的 IIS 设置正确!!
但是当我尝试添加对客户端的引用时,问题就开始了。只有我看到 http 端点,没有 net.tcp。
这是我的服务配置:
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5"/>
</system.web>
<system.serviceModel>
<services>
<service name="MYSERVICE.SERVICE" behaviorConfiguration="behavior1">
<endpoint
binding="netTcpBinding"
contract="MYSERVICE.ISERVICE">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:60745/MYSERVICE/SERVICE/"/>
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="behavior1">
<serviceMetadata httpGetEnabled="false" httpsGetEnabled="false"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<protocolMapping>
<add binding="netTcpBinding" scheme="net.tcp" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<directoryBrowse enabled="true"/>
</system.webServer>
</configuration>
注意:我的网站从 60745 地址开始,但是对于 IIS 中的 net.tcp 绑定,我添加了 60746:* 我还为两个端口打开了入站出站规则。
谢谢!
【问题讨论】:
-
您是否在 IIS 服务器上的 Windows 功能中开启了“Windows Communication Foundation Non-HTTP Activation”?
-
如果您的程序是 .NET 4.5,您是否在 .NET Framework 4.5 高级服务中打开了 TCP 激活(如果您运行 IIS 的操作系统有)
-
这是什么意思?我的服务 TCP 激活器和端口共享正在工作。我找不到这个 TCP 激活。第一次听说
-
我通过了 TCP 激活。
-
那我没主意了,抱歉 :(