2011-07-26 25 views
1

我正在學習WCF並開發了一個服務,首先使用wsHttpBinding並將其託管在IIS7(win7)上,並從Windows客戶端應用程序使用該服務。它工作正常(使用WCF服務DLL方法)有兩個端點的問題:wsHttpBinding和netTCPBinding

我試圖有兩個端點,並添加netTCpBinding。我遇到一個錯誤

{該TransportManager失敗使用 NetTcpPortSharing服務所提供的URI聽:無法啓動服務,因爲它是 禁用。

我已經開始所需的服務,甚至重新啓動我的機器。在「服務」中,2個服務顯示爲自己啓動..我已經在IIS中啓用了所需的tcpnetbinding設置,並由許多博客和msdn通知。

我的客戶端應用程序的配置是這樣的:

<configuration>  
    <system.serviceModel> 
     <bindings /> 
     <client> 
      <endpoint name="httpEndpoint" 
       address="http://MachineName:8000/FLOW5WCFService.svc" 
       binding="wsHttpBinding" 
       contract="FLOW5ServiceDLL.IFLOW5WCFService"/> 
      <endpoint name="tcpEndpoint" 
       address="net.tcp://MachineName:8082/FLOW5WCFService.svc" 
       binding="netTcpBinding" 
       contract="FLOW5ServiceDLL.IFLOW5WCFService"/> 
     </client> 
    </system.serviceModel> 
</configuration> 

服務web.config

<configuration> 
    <system.serviceModel> 
     <bindings> 
     <netTcpBinding> 
       <binding name="tcpBinding" 
        portSharingEnabled="true" 
        closeTimeout="00:10:00" openTimeout="00:10:00" 
        receiveTimeout="00:10:00" sendTimeout="00:10:00" transactionFlow="true" 
        hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288" 
        maxReceivedMessageSize="2147483647"> 
        <readerQuotas maxDepth="32" maxStringContentLength="2147483647" 
         maxArrayLength="2147483647" maxBytesPerRead="4096" 
         maxNameTableCharCount="320000" /> 
       </binding> 
     </netTcpBinding> 
     </bindings> 
     <services> 
      <service behaviorConfiguration="FLOW5ServiceDLL.FLOW5WCFServiceBehaviour" 
        name="FLOW5ServiceDLL.FLOW5WCFService"> 
      <endpoint 
       address="" 
       binding="wsHttpBinding" 
       contract="FLOW5ServiceDLL.IFLOW5WCFService"> 
       <identity> 
        <dns value="localhost" /> 
       </identity> 
      </endpoint> 
      <endpoint 
       binding="netTcpBinding" 
       bindingConfiguration="tcpBinding" 
       contract="FLOW5ServiceDLL.IFLOW5WCFService"/> 
      <endpoint 
       address="mex" 
       binding="mexHttpBinding" 
       contract="IMetadataExchange" /> 
      <host> 
       <baseAddresses> 
        <add baseAddress="http://localhost:8000/" /> 
        <add baseAddress="net.tcp://localhost:8082" /> 
       </baseAddresses> 
      </host> 
     </service> 
    </services> 
    <behaviors> 
     <serviceBehaviors> 
      <behavior name="FLOW5ServiceDLL.FLOW5WCFServiceBehaviour"> 
       <serviceMetadata httpGetEnabled="false" /> 
       <serviceDebug includeExceptionDetailInFaults="false" /> 
      </behavior> 
     </serviceBehaviors> 
    </behaviors> 
</system.serviceModel> 
<system.web> 
    <compilation debug="false" /> 
</system.web> 
</configuration> 

我創建一個頻道在我的客戶端代碼如下

ChannelFactory<IFLOW5WCFService> protocolFactory 
     = new ChannelFactory<IFLOW5WCFService>("tcpEndpoint"); 
l_oFLOW5Service = protocolFactory.CreateChannel(); 

任何人都可以請讓我知道如果我的配置錯誤或者是我需要做的任何其他設置?請讓我知道的情況下,任何更多的信息,需要提前

+0

沒有人需要更多信息嗎?沒有答案!! ..請讓我知道,如果有人發現了更多的事情要做.. – srivatsayb

回答

1

感謝我看到兩件事情:

1)在您的服務器的web.config,您netTcp端點沒有一個地址。如果你想有默認的基本地址netTcp端點監聽net.Tcp,我仍然會一直把一個address=""到我的終點:

<endpoint 
    address="" 
    binding="netTcpBinding" 
    bindingConfiguration="tcpBinding" 
    contract="FLOW5ServiceDLL.IFLOW5WCFService"/> 

2)在你的客戶,你不定義任何netTcpBinding配置,而在服務器端,你呢。目前我沒有看到任何關鍵設置 - 但爲了安全起見,我建議嘗試在您的客戶端配置中使用相同的netTcpBinding配置,並在客戶端的tcpEndpoint中使用該配置並查看是否有任何區別。

如果沒有任何作用:爲什麼不嘗試禁用/關閉服務器端的NetTcp端口共享?在這個例子中,我真的不需要這麼做 - 只要不需要它就可以相處 - 只要你不需要它。

+0

1)我有地址添加之前,它仍然沒有工作... 2)嗯..因爲我很多我讀,綁定配置是不需要在我的客戶端配置..但正如你所說,你永遠不知道,我會嘗試它.. 我以爲NetTcp端口共享服務是defaulty需要使用netTcpBinding,我會反正把它關掉,檢查..謝謝正確編輯我的問題.. – srivatsayb