不支持协议'net.tcp'

Deb*_*mar 6 wcf wcf-binding

我的WCF服务给了我"不支持协议'net.tcp'"......

<system.serviceModel>
        <bindings>
      <netTcpBinding>
        <binding name="tcpBinding" transferMode="Streamed" portSharingEnabled="false">
            <reliableSession enabled="true" />
          <security mode="None">
            <transport clientCredentialType="None" protectionLevel="None" />
            <message clientCredentialType="None" />
          </security>
        </binding>
      </netTcpBinding>
    </bindings>
        <services>
            <service name="JMSysSplash.CommunicationServer.JMSysSplashServer" behaviorConfiguration="Service1Behavior">
                <endpoint address="" binding="wsHttpBinding" contract="JMSysSplash.CommunicationClient.IJMSysSplashServer">
                    <identity>
                        <dns value="localhost"/>
                    </identity>
                </endpoint>
                <endpoint address="mex" binding="mexHttpBinding"  contract="IMetadataExchange"/>
        <endpoint address="net.tcp://localhost:8888/JMSysSplashServer" binding="netTcpBinding" bindingConfiguration="tcpBinding" contract="JMSysSplash.CommunicationClient.IJMSysSplashServer"/>
                <host>
                    <baseAddresses>
                        <add baseAddress="http://localhost:8731/JMSysSplashServer.svc/"/>
           <add baseAddress="net.tcp://localhost:8888/JMSysSplashServer"/> 
          </baseAddresses>
                </host>
            </service>
        </services>    
        <behaviors>
            <serviceBehaviors>
                <behavior name="Service1Behavior">
                    <serviceMetadata httpGetEnabled="true"/>
                    <serviceDebug includeExceptionDetailInFaults="true"/>
                </behavior>
            </serviceBehaviors>
        </behaviors>
Run Code Online (Sandbox Code Playgroud)

小智 11

请检查是否安装了".NET功能 - > WCF激活 - >非HTTP激活"功能("服务器管理器 - >添加/删除功能").我假设您在IIS中托管服务.在这种情况下,还请检查网站是否允许net.tcp协议(网站 - >高级设置 - >启用的协议)和"Net.Tcp Listner适配器"Windows服务正在运行.


mar*_*c_s 0

您缺少 nettcp 的基地址 - 或者您需要在端点中定义完整的 netTCP 地址。您当前的 netTcp 端点如下所示:

       <endpoint address="" binding="netTcpBinding" 
Run Code Online (Sandbox Code Playgroud)

您没有指定完整的地址 --> WCF 正在寻找可供 net.tcp 使用的基地址- 但没有!

解决方案 1baseAddress :为 netTcp添加一个:

<services>
    <service name="JMSysSplash.CommunicationServer.JMSysSplashServer" behaviorConfiguration="Service1Behavior">
        .....
        <host>
            <baseAddresses>
                <add baseAddress="http://localhost:8731/JMSysSplashServer.svc/"/>
                <add baseAddress="net.tcp://localhost:8888/JMSysSplashServer"/>
            </baseAddresses>
        </host>
    </service>
</services>
Run Code Online (Sandbox Code Playgroud)

现在您的 net.tcp 端点可以到达net.tcp://localhost:8888/JMSysSplashServer

解决方案 2:在 net.Tcp 端点中定义完整地址:

<services>
    <service name="JMSysSplash.CommunicationServer.JMSysSplashServer" 
             behaviorConfiguration="Service1Behavior">
        <endpoint address="" binding="wsHttpBinding" 
                  contract="JMSysSplash.CommunicationClient.IJMSysSplashServer">
            <identity>
                <dns value="localhost"/>
            </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding"  
                  contract="IMetadataExchange"/>
        <endpoint 
             address="net.tcp://localhost:8888/JMSysSplashServer" 
             binding="netTcpBinding" bindingConfiguration="tcpBinding"  
             contract="JMSysSplash.CommunicationClient.IJMSysSplashServer"/>
        .......
    </service>
</services>
Run Code Online (Sandbox Code Playgroud)

当您定义端点时,您

  • 要么定义一个完整的地址(带有net.tcp端口号和全部)

或者:

  • 您定义一个相对地址(例如address=""),但在这种情况下,您必须有该方案的基地址(此处:)net.tcp- 不仅仅是一个 http 基地址