关于WCF的问题不支持协议“net.tcp”
首先,我创建了一个WCF服务应用程序,其中创建了svc文件。然后我编写与服务相关的小代码。当我点击F5时,wcf测试客户端显示良好,当我选择svc文件并选择浏览器中的视图选项时,一切正常。最初,我在配置文件中只有一个端点…那就是wsDualHttpBinding,然后一切正常 当我添加另一个名为netTcpBinding的端点时,问题就开始了。在配置文件中添加netTcpBinding端点后,当我尝试在浏览器中再次浏览svc文件时,我收到一条错误消息,称为“net.tcp”协议不受支持,当我点击F5时,wcf测试客户端显示一条错误消息,称为**无法从中获取元数据http://localhost:30996/ChatService.svc** 我只是不明白当我添加netTcpBinding时为什么会发生这种情况。有一点我想说的是,我没有在任何地方主持过我的服务。我只需创建WCF服务应用程序并在web.config文件中添加所有条目,然后按F5。这就是我没有在任何地方托管服务而出错的原因吗 下面是我的配置细节关于WCF的问题不支持协议“net.tcp”,wcf,Wcf,首先,我创建了一个WCF服务应用程序,其中创建了svc文件。然后我编写与服务相关的小代码。当我点击F5时,wcf测试客户端显示良好,当我选择svc文件并选择浏览器中的视图选项时,一切正常。最初,我在配置文件中只有一个端点…那就是wsDualHttpBinding,然后一切正常 当我添加另一个名为netTcpBinding的端点时,问题就开始了。在配置文件中添加netTcpBinding端点后,当我尝试在浏览器中再次浏览svc文件时,我收到一条错误消息,称为“net.tcp”协议不受支持,当我点击
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<services>
<service name="BBAChatService.ChatService" behaviorConfiguration="BBAChatService.ChatServiceBehavior" >
<host>
<baseAddresses>
<add baseAddress ="http://localhost:30996/ChatService.svc/"/>
<add baseAddress ="net.tcp://localhost:30997/ChatService/"/>
</baseAddresses>
</host>
<endpoint name="dual_bind"
address="dual"
binding="wsDualHttpBinding"
bindingConfiguration="WSDualHttpBinding_IChatService"
contract="BBAChatService.IChatService">
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
<endpoint name="tcp_bind"
address="net.tcp://localhost:30997/ChatService"
binding="netTcpBinding"
bindingConfiguration="tcpBinding"
contract="BBAChatService.IChatService">
</endpoint>
<endpoint address="net.tcp://localhost:30997/ChatService/mex"
binding="mexTcpBinding"
contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="BBAChatService.ChatServiceBehavior">
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<netTcpBinding>
<binding name="tcpBinding"
maxBufferSize="67108864"
maxReceivedMessageSize="67108864"
maxBufferPoolSize="67108864"
transferMode="Buffered"
closeTimeout="00:00:10"
openTimeout="00:00:10"
receiveTimeout="00:20:00"
sendTimeout="00:01:00"
portSharingEnabled="true"
maxConnections="100">
<security mode="None">
</security>
<readerQuotas maxArrayLength="67108864"
maxBytesPerRead="67108864"
maxStringContentLength="67108864"/>
<reliableSession enabled="true" inactivityTimeout="00:20:00"/>
</binding>
</netTcpBinding>
<wsDualHttpBinding>
<binding name="WSDualHttpBinding_IChatService"
closeTimeout="00:01:00"
openTimeout="00:01:00"
receiveTimeout="00:10:00"
sendTimeout="00:01:00"
bypassProxyOnLocal="false"
transactionFlow="false"
hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288"
maxReceivedMessageSize="65536"
messageEncoding="Text"
textEncoding="utf-8"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32"
maxStringContentLength="8192"
maxArrayLength="16384"
maxBytesPerRead="4096"
maxNameTableCharCount="16384"/>
<reliableSession
ordered="true"
inactivityTimeout="00:10:00"/>
<security mode="Message">
<message clientCredentialType="Windows"
negotiateServiceCredential="true"
algorithmSuite="Default"/>
</security>
</binding>
</wsDualHttpBinding>
</bindings>
</system.serviceModel>
</configuration>
请告诉我缺少什么…我需要在配置文件中更改什么
这是我的项目解决方案资源管理器的屏幕截图
当您点击F5时,VS使用的内置web服务器仅支持HTTP激活,因此您将无法在其中承载net.tcp端点。您可以: 在启用非HTTP激活的情况下将其托管在IIS中 为您的服务编写一个简单的主机应用程序 使用WcfSvcHost.exe,该文件可在%VS INSTALLATION DIR%\Common7\IDE中找到 正确承载服务后,必须为其创建元数据交换端点绑定类型为mexTcpBinding,并在net.tcp端点的行为配置中将httpGetEnabled设置为false
<serviceBehaviors>
<behavior name="BehaviorName">
<serviceMetadata httpGetEnabled="false" />
</behavior>
<serviceBehaviors>
编辑:
有关WcfSvcHost.exe的详细使用说明,请参阅。至于httpGetEnabled,我的意思是在net.tcp服务端点的行为中,在serviceMetadata上将其设置为false
<serviceBehaviors>
<behavior name="BehaviorName">
<serviceMetadata httpGetEnabled="false" />
</behavior>
<serviceBehaviors>
然后将此行为应用于net.tcp端点。我假设您希望通过TCP而不是HTTP为此端点公开元数据,在这种情况下,您需要包括一个mexTcpBinding端点。谢谢您的回答。你能告诉我如何使用WcfSvcHost.exe托管服务吗。我希望您已经看到我的服务有两个端点,一个是dula,另一个是tcp。请告诉我是否可以为两个端点使用WcfSvcHost.exe托管。为什么要将httpGetEnabled设置为false??如果我不这样做,那么会出现什么问题。谢谢为什么我应该将httpGetEnabled设置为false。我认为如果我将其设为false,那么在创建代理时将不会发现服务。请告诉我为什么需要将httpGetEnabled设置为false。谢谢您的回答。如果您为httpGetEnabled提供一个小的配置代码块,这将非常有帮助,因此我可以可视化设置httpGetEnabled=false的位置。谢谢我也给了你一票…谢谢。我仍然有一个困惑,元数据通过mex端点公开,那么为什么我需要设置httpGetEnabled=false呢。若我只有一个tcpbinding,那个么我可以声明一个mex端点,这将足以公开元数据,客户端可以通过该元数据创建代理。为什么你说我需要一个用于tcp的mexTcpBinding…就像知道简单的mex端点不适用于tcp一样?我在这里问了两个问题。一个是相关的httpGetEnabled=false,另一个是用于mexTcpBinding而不是普通的mex绑定。您实际上没有义务将httpGetEnabled设置为false,因为默认情况下它是false。我只是觉得明确地指定这个更具表现力。对不起,我真的不明白你的问题。请尝试重新措辞,或查看有关公开元数据的更多信息。也许你会在那里找到答案。
<serviceBehaviors>
<behavior name="BehaviorName">
<serviceMetadata httpGetEnabled="false" />
</behavior>
<serviceBehaviors>