在IIS(使用WAS)上托管WCF服务进行netTCP绑定的问题?

时间:2017-07-12 22:36:22

标签: c# wcf iis web was

我创建了一个简单的WCF服务,并通过创建一个新网站将其托管在IIS中。在Web.config文件中,我提供了http和net tcp的绑定。 我创建了一个控制台客户端并添加了服务引用它在客户端配置中生成两个绑定 - 用于http和用于tcp。当我尝试使用tcp调用服务时,我收到此错误 -

未处理的类型&System; Service.ServiceModel.EndpointNotFoundException'发生在mscorlib.dll中 附加信息:net.tcp://computername/Service.svc上没有可以接受该消息的端点。这通常是由错误的地址或SOAP操作引起的。

当我使用Http端点运行时,它工作正常。 注意 - 我使用的是Windows 10操作系统,安装了IIS 10.0和WPAS \ WAS(Windows进程激活服务)。我已在Windows功能中启用\检查HTTP激活,.Net框架中的TCP激活。并修改了IIS服务器设置以包含net tcp。请在附图中查看。  enter image description here

我的网站Web.config文件看起来像

 <system.serviceModel>
<bindings>
  <netTcpBinding>
    <binding name="NewBinding0" portSharingEnabled="true">
      <security mode="None"  />
    </binding>
  </netTcpBinding>
</bindings>
<services>
  <service behaviorConfiguration="My" name="WCFServiceOM.Service1"> <!--  the service name must match the configuration name for the service implementation. -->
    <endpoint address="" binding="basicHttpBinding" contract="WCFServiceOM.IService1"/>
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
    <endpoint  binding="netTcpBinding" bindingConfiguration="NewBinding0" contract="WCFServiceOM.IService1" />
    <endpoint address="mexOM" binding="mexTcpBinding" contract="IMetadataExchange"/>
    <host>
      <baseAddresses>
        <add baseAddress="net.tcp://localhost:8087/Service1" />
        <add baseAddress="http://localhost:7777/Service1"/>
      </baseAddresses>
    </host>
  </service>
</services>
<behaviors>
  <endpointBehaviors>
    <behavior name="webBehanior">
      <webHttp/>
    </behavior>
  </endpointBehaviors>
  <serviceBehaviors>
    <behavior name="My">
      <!-- To avoid disclosing metadata information, set the values below to false before deployment -->
      <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
      <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
      <serviceDebug includeExceptionDetailInFaults="true"/>
    </behavior>
  </serviceBehaviors>
</behaviors>

我的客户端App.Config看起来像

<configuration>
<startup> 
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6" />
</startup>
<system.serviceModel>      
    <bindings>
        <basicHttpBinding>
            <binding name="BasicHttpBinding_IService1" />
        </basicHttpBinding>
        <netTcpBinding>
            <binding name="NetTcpBinding_IService1">
                <security mode="None" />
            </binding>
        </netTcpBinding>
    </bindings>
    <client>
        <endpoint address="http://computername:7777/Service.svc"
            binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService1"
            contract="ServiceReference1.IService1" name="BasicHttpBinding_IService1" />
        <endpoint address="net.tcp://computername/Service.svc" binding="netTcpBinding"
            bindingConfiguration="NetTcpBinding_IService1" contract="ServiceReference1.IService1"
            name="NetTcpBinding_IService1" />
    </client>
</system.serviceModel>

0 个答案:

没有答案