如何设置WCF Net.Tcp

时间:2011-01-27 18:14:29

标签: wcf nettcpbinding

我正在尝试设置一个wcf服务,以便在IIS 7上使用net.tcp。

这是我得到的错误:

  

没有终点收听   的net.tcp://127.0.0.1:8000 / ListingService   那可以接受这个消息。这是   通常由不正确的地址引起   或SOAP动作。请参阅InnerException,if   目前,了解更多详情。

以下是我从客户端调用的代码:

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>

有什么想法吗?

1 个答案:

答案 0 :(得分:7)

此配置在IIS / WAS中不起作用。在IIS中托管时,您需要.svc文件(或WCF 4中基于配置的激活),并且端点的地址始终是在端点配置中指定的VirtualDirectoryPath + SvcFile +相对地址。在端点配置中设置绝对地址是为了自托管。