简体   繁体   中英

Protocol 'net.tcp' is not supported

I am changing my wcf hosting from a Windows service to be hosted in a IIS.

I have added in my solution a wcf Service Appliction and I have added reference to my projects and edited the svc file to this

<%@ ServiceHost Language="C#" Debug="true"
Service="EFG.Acc.CashService.ServiceFactory.CashService" %>

then I have configured web.config and define bindings which will be netTcp binding and endpoints.

I have enabled my IIS website settings to Enabled Protocols to http.nettcp and same exception.

I have an got this exception while browsing my service.svc file:

**protocol 'net.tcp' is not supported. 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 
Exception Details: System.InvalidOperationException: The protocol 'net.tcp' is not supported.
Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.  
Stack Trace: 
[InvalidOperationException: The protocol 'net.tcp' is not supported.]
   System.ServiceModel.Activation.HostedTransportConfigurationManager.InternalGetConfiguration(String scheme) +98668
   System.ServiceModel.Activation.HostedAspNetEnvironment.GetBaseUri(String transportScheme, Uri listenUri) +24
   System.ServiceModel.Channels.TransportChannelListener.OnOpening() +12200164
   System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) +274
   System.ServiceModel.Channels.DelegatingChannelListener`1.OnOpen(TimeSpan timeout) +112
   System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) +318
   System.ServiceModel.Dispatcher.ChannelDispatcher.OnOpen(TimeSpan timeout) +72**

And here is my Web.config file

<?xml version="1.0"?>
<configuration>

  <system.web>
    <compilation debug="false" targetFramework="4.0" />
  </system.web>

  <system.serviceModel>
    <bindings>
      <netTcpBinding>
        <binding name="NetTcpBinding"
                 transactionFlow="true"
                 listenBacklog="100"
                 maxConnections="5000"/>
      </netTcpBinding>
    </bindings>
    <services>
      <service name="EFG.Acc.CashService.ServiceFactory.CashService">
        <endpoint address="net.tcp://localhost:8000" binding="netTcpBinding"
          bindingConfiguration="NetTcpBinding" name="netTcpEndPoint" bindingName="CashServiceTCP"
          contract="EFG.Acc.CashService.Contracts.Interfaces.ICashService" />
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:7000"/>

          </baseAddresses>
        </host>

      </service>
    </services>
    <protocolMapping>
      <add scheme="net.tcp" binding="netTcpBinding" bindingConfiguration="NetTcpBinding"/>
    </protocolMapping>
    <behaviors>
      <serviceBehaviors>
        <behavior>
           <!--To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment--> 
          <serviceMetadata httpGetEnabled="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="false"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <client>
      <endpoint address="net.tcp://localhost:8000/CashService" binding="netTcpBinding" bindingConfiguration="NetTcpBinding" contract="EFG.Acc.CashService.Contracts.Interfaces.ICashService" name="CashServiceTCP2" />
    </client>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />

  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>

</configuration>

Try read this carefully: http://blogs.msdn.com/b/james_osbornes_blog/archive/2010/12/07/hosting-in-iis-using-nettcpbinding.aspx

+

  • You are using nettcpbinding with http baseAddress

  • Add metadata endpoint while testing

  • I use nettcp binding with IIS many times and everytime without 'protocolMapping'

  • I recommend to use absolute address in baseAddress only (matching protocol net.tcp://!) and relative - in endpoint addresses

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM