在IIS托管NET TCP / HTTP WCF(NET TCP/HTTP WCF Hosted i

2019-07-30 07:56发布

我是新来的WCF和IIS,但一直在做如何承载在IIS中的WCF应用程序上的一些阅读。 我们有我们试图将其部署到IIS这就需要HTTP和端点的net.tcp的系统。 我所拥有的一切配置,因为我在随机教程看到,但我仍然无法从我的客户端连接。 与配置的任何帮助,将不胜感激!

我EdWCF.svc文件在我的WCF目录:

< %@ 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>

感谢您的任何帮助或建议!

Answer 1:

  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>


文章来源: NET TCP/HTTP WCF Hosted in IIS