WCF服务netTCPbinding

Ash*_*shu 8 wcf web-services wcf-binding

我想使用netTCPbinding,所以我改变了我的web配置,如下所示.我遇到了这个错误:

无法找到与绑定NetTcpBinding的端点匹配scheme net.tcp的基址.注册的基地址方案是[http].

怎么解决这个问题?

<services>
  <service name="DXDirectory.DXDirectoryService" behaviorConfiguration="DXDirectory.Service1Behavior">
    <!-- Service Endpoints -->
    <endpoint address="" binding="netTcpBinding" bindingConfiguration="WindowsSecured" contract="DXDirectory.IDXDirectoryService">
      <!-- 
          Upon deployment, the following identity element should be removed or replaced to reflect the 
          identity under which the deployed service runs.  If removed, WCF will infer an appropriate identity 
          automatically.
      -->
      <identity>
        <dns value="localhost" />
      </identity>
    </endpoint>
    <host>
      <baseAddresses>
        <add baseAddress="net.tcp://localhost:2582/DXDirectoryService" />
      </baseAddresses>
    </host>

  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior name="DXDirectory.Service1Behavior">
      <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
      <serviceMetadata httpGetEnabled="false" />
      <!-- 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="false" />
      <serviceAuthorization principalPermissionMode="UseWindowsGroups" />
      <!--<serviceCredentials>-->
        <!--<userNameAuthentication userNamePasswordValidationMode="Custom"
                                membershipProviderName="CustomUserNameValidator"/>-->
      <!--</serviceCredentials>-->
    </behavior>
  </serviceBehaviors>
</behaviors>
Run Code Online (Sandbox Code Playgroud)

mar*_*c_s 5

HMm ...您已将基地址添加到您的服务/主机部分确定.

快速提问:你是自托管,还是在IIS托管?哪个版本的IIS?

IIS5/6仅支持HTTP连接 - 您无法在IIS 5/6中托管NetTCP.

在IIS7中,您必须手动执行一系列步骤以启用非HTTP绑定,但这是可能的.有关如何实现此目的,请参阅此MSDN文章.

自托管是最佳选择 - 您可以获得所有绑定并完全控制您托管的服务.