首先,我创建了一个 WCF 服务应用程序,其中创建了 svc 文件。然后我写我的小服务相关代码。当我按 F5 时,wcf 测试客户端显示正常,当我选择 svc 文件并在浏览器选项中选择视图时,一切正常。最初我在配置文件中只有一个端点......那就是wsDualHttpBinding然后一切正常。
当我添加另一个名为netTcpBinding的端点时,问题就开始了。在配置文件中添加 netTcpBinding 端点后,当我尝试在浏览器中再次浏览 svc 文件时,我收到名为The protocol 'net.tcp' is not supported 的错误消息,当我按 F5 时,wcf 测试客户端显示错误消息称为** Cannot obtain Metadata from http://localhost:30996/ChatService.svc**
我只是不明白为什么当我添加 netTcpBinding 时会发生这种情况。我想说的是我没有在任何地方托管我的服务。我只是创建 WCF 服务应用程序并在 web.config 文件中添加所有条目,然后按 F5。这是因为我没有在任何地方托管我的服务而出现错误的原因吗?
所以这是我的配置细节如下
<?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>
只是告诉我缺少什么......我需要在我的配置文件中进行更改。
这是我的项目解决方案资源管理器的屏幕截图。