2011-01-27 48 views
1

我試圖建立一個WCF服務在IIS 7如何建立WCF的net.tcp

這裏使用的net.tcp是錯誤,我得到:

有沒有終點的聆聽在 的net.tcp://127.0.0.1:8000/ListingService 是可以接受的消息。這通常是由不正確的地址 或SOAP操作導致的 。有關更多詳細信息,請參見InnerException,如果存在 。

下面是我從客戶端調用代碼:

using (var client = new ListingServiceClient("NetTcpBinding")) 
{ 
    client.Test(); 
    client.Close(); 
} 

這裏是我的服務的web.config - http://pastebin.com/3S8BZbup

<system.serviceModel> 
    <bindings> 
     <netTcpBinding> 
     <binding portSharingEnabled="true"> 
      <security mode="None" /> 
     </binding> 
     </netTcpBinding> 
    </bindings> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior name="default"> 
      <serviceMetadata httpGetEnabled="true"/> 
      <serviceDebug includeExceptionDetailInFaults="true"/> 
      <!--throttle service--> 
      <serviceThrottling 
      maxConcurrentCalls="10000" 
      maxConcurrentSessions="10000" 
      maxConcurrentInstances="10000" /> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    <services> 
     <service behaviorConfiguration="default" name="Housters.Services.ListingService"> 
     <endpoint name="TcpEndpoint" 
        address="net.tcp://127.0.0.1:8000/ListingService" 
        binding="netTcpBinding" 
        contract="Housters.Services.IListingService" /> 
     </service> 
    </services> 
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" /> 
    </system.serviceModel> 
    <system.webServer> 
     <modules runAllManagedModulesForAllRequests="true"/> 
    </system.webServer> 

這裏是我的客戶的app.config - http://pastebin.com/YpiAhh46

<system.serviceModel> 
    <bindings> 
     <netTcpBinding> 
     <binding name="NetTcpBinding"> 
      <security mode="None"/> 
     </binding> 
     </netTcpBinding> 
    </bindings> 
    <client> 
     <endpoint 
       address="net.tcp://127.0.0.1:8000/ListingService" 
       binding="netTcpBinding" bindingConfiguration="NetTcpBinding" 
       contract="ListingServiceProxy.IListingService" name="NetTcpBinding" /> 
    </client> 
    </system.serviceModel> 

任何ID EAS?

+0

我還要提到的是我在啓用IIS協議添加的net.tcp,並增加了一個的net.tcp綁定 - 「8000:*」。 – Justin 2011-01-27 18:16:36

+0

不知道這是一個問題,但我注意到,你不設置`bindingConfiguration`財產的「TcpEndpoint」`endpoint`。 `netTcpBinding`上也沒有設置`name`。 – vlad 2011-01-27 18:22:51

回答

7

這樣的配置不會在IIS工作/ WAS。在IIS中託管時,需要.svc文件(或WCF 4中的基於配置的激活),並且端點的地址始終爲VirtualDirectoryPath + SvcFile +在端點配置中指定的相對地址。在端點配置中設置絕對地址用於自託管。