2012-07-10 91 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