2012-07-10 79 views
7

我是WCF和IIS的新手,但一直在研究如何在IIS中託管WCF應用程序。我們有一個系統要部署到需要HTTP和NET.TCP端點的IIS。隨機教程中我看到了所有配置,但仍無法從我的客戶端連接。任何幫助與配置將不勝感激!在我的WCF目錄在IIS中託管的NET TCP/HTTP WCF

我EdWCF.svc文件:

< %@ ServiceHost Language="C#" Debug="true" Service="TwoFour.WCF.Engine.EdWCF" % > 

我的web.config:

<?xml version="1.0"?> 
<configuration> 
<system.serviceModel> 

    <behaviors> 
     <serviceBehaviors> 
     <behavior name="MyBehaviour"> 
      <serviceMetadata HttpGetEnabled="True" /> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 

<service name="TwoFour.WCF.Engine.EdWCF" behaviorConfiguration="MyBehaviour"> 
     <host> 
      <baseAddresses> 
      <add baseAddress="net.tcp://localhost:12345/WCF/EdWCF.svc"/> 
      </baseAddresses> 
     </host> 
     <endpoint address="" 
       binding="netTcpBinding" 
       bindingConfiguration="InsecureTcp" 
       contract="TwoFour.WCF.Interface.Shared.IEdWCF" /> 
     <endpoint address="mexhttp" binding="mexHttpBinding" contract="IMetadataExchange"/> 
</service> 

    <bindings> 
      <netTcpBinding> 
       <binding name="InsecureTcp" portSharingEnabled="true"> 
        <security mode="None" /> 
       </binding> 
      </netTcpBinding> 
     </bindings> 

</system.serviceModel> 

</configuration> 

感謝任何幫助或建議!

回答

13
  1. 在IIS添加net.tcp綁定到啓用的協議列表(疥網站 - >高級設置 - >啓用的協議)

  2. 在網站添加綁定net.tcp綁定(編輯綁定 - >添加 - >選擇類型的net.tcp並添加端口這樣的12345:*)

你還需要在你的配置到指定的基地址:

<system.serviceModel> 
<services> 
    <host> 
     <baseAddresses> 
     <add baseAddress="net.tcp://server:12345/ServiceAddress.svc"/> 
     </baseAddresses> 
    </host> 
    ... 
</service> 
    ... 
</system.serviceModel> 

編輯:

試試這個

<system.serviceModel> 

    <behaviors> 
     <serviceBehaviors> 
     <behavior name="MyBehaviour"> 
      <serviceMetadata /> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 

<service name="TwoFour.WCF.Engine.EdWCF" behaviorConfiguration="MyBehaviour"> 
     <host> 
      <baseAddresses> 
      <add baseAddress="net.tcp://localhost:12345/WCF/EdWCF.svc"/> 
      </baseAddresses> 
     </host> 
     <endpoint address="" 
       binding="netTcpBinding" 
       bindingConfiguration="InsecureTcp" 
       contract="TwoFour.WCF.Interface.Shared.IEdWCF" /> 
     <endpoint address="mextcp" binding="mexTcpBinding" contract="IMetadataExchange"/> 
</service> 

    <bindings> 
      <netTcpBinding> 
       <binding name="InsecureTcp" portSharingEnabled="true"> 
        <security mode="None" /> 
       </binding> 
      </netTcpBinding> 
     </bindings> 

</system.serviceModel> 
+0

感謝您的快速回復。我已經啓用了綁定,並且我只是將主機基地址添加到了我的配置文件baseAddress =「net.tcp:// localhost:12345/EdWCF.svc」 - 仍然無法連接。 – 2012-07-10 13:03:56

+0

你需要添加完整的地址。如果EdWCF.svc位於Engine文件夾中,請將其更改爲net.tcp:// localhost:12345/Engine/EdWCF.svc – 2012-07-10 13:08:01

+0

我的IIS應用程序的物理路徑設置爲C:\ User \ WCF \ WCF,其中EdWCF .svc文件位於。我調整了基地址net.tcp:// localhost:12345/WCF/EdWCF.svc,但是當我嘗試從我們的客戶端連接時,我仍然得到:無法連接到net.tcp:// localhost:12345/WCF /EdWCF.svc。連接嘗試持續時間爲00:00:02.0052005。 TCP錯誤代碼10061:由於目標機器主動拒絕它127.0.0.1:12345,因此無法建立連接。 – 2012-07-10 13:15:19