首先我創建在其中創建SVC文件WCF服務的應用程序。然後我寫我的小服務相關的代碼。 當我按F5然後WCF測試客戶端出現罰款,當我在瀏覽器選項中選擇SVC文件,並選擇視圖,則一切正常。最初我只有一個端點在配置文件...這是wsDualHttpBinding然後一切工作正常。協議「的net.tcp」不支持有關問題WCF
現在我添加另一個端點叫netTcpBinding然後問題開始。在配置文件中添加NetTcpBinding的終點,當我在瀏覽器再次嘗試瀏覽SVC文件,然後我得到了錯誤消息稱爲協議「的net.tcp」後,不支持,當我按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>
只是告訴我什麼是缺少....我需要在我的配置文件來改變。
這裏是我的項目的解決方案資源管理器的屏幕截圖。
感謝您的回答。你可以請指導我如何託管服務與WcfSvcHost.exe。我希望你看到我的服務有兩個端點,一個是dula,另一個是tcp。告訴我可以爲WcfSvcHost.exe託管兩個端點。爲什麼我應該設置httpGetEnabled = false?如果我不這樣做,那麼可能會發生什麼問題。謝謝 – Thomas
爲什麼我應該設置httpGetEnabled爲false。我認爲如果我把它設置爲假,那麼服務在代理創建時不會被發現。請告訴我爲什麼需要將httpGetEnabled設置爲false。 – Thomas
感謝您的回答。如果您爲httpGetEnabled提供小配置代碼塊,結果我可以可視化設置httpGetEnabled = false的位置將會很有幫助。謝謝 – Thomas