2009-08-28 101 views
2

工作,下面是我的app.config麻煩WCF與NetTcpBinding的

<?xml version="1.0" encoding="utf-8" ?> 
<configuration> 
    <system.serviceModel> 
    <services> 
     <service name="Indexer"> 
     <endpoint address="net.tcp://localhost:8000/Indexer/" binding="netTcpBinding" 
      bindingConfiguration="TransactionalTCP" contract="Me.IIndexer" /> 
     </service> 
     <service name = "Indexer" behaviorConfiguration = "MEXGET"> 
     <host> 
      <baseAddresses> 
      <add baseAddress = "http://localhost:8000/"/> 
      </baseAddresses> 
     </host> 
     </service> 
    </services> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior name = "MEXGET"> 
      <serviceMetadata httpGetEnabled = "true"/> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    <bindings> 
     <netTcpBinding> 
     <binding name="TransactionalTCP" 
      transactionFlow="true" 
     /> 
     </netTcpBinding> 
    </bindings> 
    </system.serviceModel> 
</configuration> 

出於某種原因,我不能去,我運行此機器上的WCF服務。 任何一個可以發現錯誤?我有netTcpBinding服務啓動並運行。

當我有同樣運行在HTTP它是工作的罰款與以下config文件

<?xml version="1.0" encoding="utf-8" ?> 
<configuration> 
    <system.serviceModel> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior name="IndexerServiceBehavior"> 
      <serviceMetadata httpGetEnabled="true" httpGetUrl="http://localhost:8080/Indexer/"/> 
      <serviceDebug includeExceptionDetailInFaults="True" /> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    <services> 
     <service name="Indexer" behaviorConfiguration="IndexerServiceBehavior"> 
     <endpoint address="http://localhost:8080/Indexer/" binding="basicHttpBinding" 
      bindingConfiguration="" name="HTTP" contract="IIndexer" /> 
     <endpoint address="http://localhost:8080/Indexer/MEX/" binding="mexHttpBinding" 
      bindingConfiguration="" name="MEX" contract="IMetadataExchange" /> 
     </service> 
    </services> 
    </system.serviceModel> 
</configuration> 

我真的不能找出我在做什麼錯..

回答

3

你當然打開防火牆讓它聽?

如果它的任何使用,這裏是我成功地使用就在不久前的結合:

<services> 

    <service name="MyService.MySearch" behaviorConfiguration="ServiceBehavior"> 
    <host> 
     <baseAddresses> 
     <add baseAddress="http://mypc:8003/MyService"/> 
     </baseAddresses> 
    </host> 
    <endpoint bindingConfiguration="Binding1" 
       binding="netTcpBinding" 
       contract="MyService.IMySearch" 
       address="net.tcp://mypc:8004/MyService" /> 
    </service> 
</services> 
<bindings> 
    <netTcpBinding> 
    <binding name="Binding1" 
      hostNameComparisonMode="StrongWildcard" 
      sendTimeout="00:10:00" 
      maxReceivedMessageSize="65536" 
      transferMode="Buffered" 
      portSharingEnabled="false"> 
     <security mode="None"> 
     <transport clientCredentialType="None" /> 
     <message clientCredentialType="None" /> 
     </security> 
    </binding> 
    </netTcpBinding> 
</bindings> 
<behaviors> 
    <serviceBehaviors> 
    <behavior name="ServiceBehavior"> 
     <serviceMetadata httpGetEnabled="true" httpGetUrl=""/> 
    </behavior> 
    </serviceBehaviors> 
</behaviors> 

有這個綁定沒有安全。

+0

是的,我已經這樣做了:-) – Matt 2009-08-28 03:47:17

+0

我只說了,因爲它花費了我大約二十分鐘的那一天:) – spender 2009-08-28 03:52:44

+0

啊你沒有mex端點,當你在visual studio中添加服務引用時,你能只要給它net.tcp地址? – Matt 2009-08-28 04:03:09

1

您可能必須Enable the Net.TCP Port Sharing Service。從MSDN報價:

Windows通訊基礎(WCF) 使用Windows服務稱爲 Net.Tcp端口共享服務,以方便 TCP端口 跨越多個進程共享。此 服務作爲WCF的一部分安裝, ,但該服務未啓用,默認爲 作爲安全預防措施,因此必須在首次使用 之前手動啓用服務 。本主題介紹如何使用Microsoft Management 控制檯(MMC)管理單元配置網絡TCP端口共享 服務 。

祝你好運!

0

嘗試爲http和net.tcp綁定使用不同的端口號。端口共享有不同的目的,在多個進程中共享相同的net.tcp端口。