Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WCF Service Library with NetTcpBinding

I'm having a tough time with NetTcpBinding.

When I run my WCFservice,I get this:

System.InvalidOperationException: Could not find a base address that matches scheme net.tcp for the endpoint with binding NetTcpBinding. Registered base address schemes are [http].
   at System.ServiceModel.ServiceHostBase.MakeAbsoluteUri(Uri relativeOrAbsoluteUri, Binding binding, UriSchemeKeyedCollection baseAddresses)
   at System.ServiceModel.Description.ConfigLoader.LoadServiceDescription(ServiceHostBase host, ServiceDescription description, ServiceElement serviceElement, Action`1 addBaseAddress)
   at System.ServiceModel.ServiceHostBase.LoadConfigurationSectionInternal(ConfigLoader configLoader, ServiceDescription description, ServiceElement serviceSection)
   at System.ServiceModel.ServiceHostBase.LoadConfigurationSectionInternal(ConfigLoader configLoader, ServiceDescription description, String configurationName)
   at System.ServiceModel.ServiceHostBase.ApplyConfiguration()
   at System.ServiceModel.ServiceHostBase.InitializeDescription(UriSchemeKeyedCollection baseAddresses)
   at System.ServiceModel.ServiceHost.InitializeDescription(Type serviceType, UriSchemeKeyedCollection baseAddresses)
   at System.ServiceModel.ServiceHost..ctor(Type serviceType, Uri[] baseAddresses)
   at Microsoft.Tools.SvcHost.ServiceHostHelper.CreateServiceHost(Type type, ServiceKind kind)
   at Microsoft.Tools.SvcHost.ServiceHostHelper.OpenService(ServiceInfo info)

I'm getting this when I run the application by default using WCFSvcHost. There's no extra code.Just the default code of any new wcf service. All I wanted to do was change the binding to tcp.

How do I solve this problem?

Edit: Here's my WCF's App.config

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.web>
    <compilation debug="true" />
  </system.web>
  <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 behaviorConfiguration="WcfServiceLibrary1.Service1Behavior"
        name="WcfServiceLibrary1.Service1">
        <endpoint address="" binding="wsHttpBinding" contract="WcfServiceLibrary1.IService1">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
        <endpoint address="Service" binding="netTcpBinding" bindingConfiguration="tcpBinding"
          name="testTcp" contract="WcfServiceLibrary1.IService1" />
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8731/Design_Time_Addresses/WcfServiceLibrary1/Service1/" />
          </baseAddresses>
        </host>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="WcfServiceLibrary1.Service1Behavior">
          <serviceMetadata httpGetEnabled="True"/>
          <serviceDebug includeExceptionDetailInFaults="False" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
</configuration>
like image 441
Josh Avatar asked Aug 19 '09 04:08

Josh


3 Answers

I'm sure by now you've fixed the issue, but it really is nothing to do with baseAddresses which is what all the bullentin boards lead you to. I found the answer at http://social.msdn.microsoft.com/forums/en-US/wcf/thread/c9f8d99d-89ee-4573-8528-a21b047bad11. Assuming you are using IIS 7.x: right click the virtual directory/application in IIS, select Manage application -> Advanced settings. In the 'Enabled Protocols' section add net.tcp, e.g.: http,net.tcp. This is necessary even if you added this protocol already at the site level.

like image 116
Helder Avatar answered Sep 20 '22 19:09

Helder


In this section

<host>          
  <baseAddresses>            
    <add baseAddress="http://localhost:8731/.../" />   
  </baseAddresses>        
</host>

add a net.tcp:// base address.

<host>
  <baseAddresses>
    <add baseAddress="http://localhost:8732/" />
    <add baseAddress="net.tcp://localhost"/>
  </baseAddresses>
</host>
like image 39
Brian Avatar answered Sep 21 '22 19:09

Brian


You can share ports, it's not too hard.

Make sure when selecting enabled protocols in IIS (right click on site -> Manage Web Site -> Advanced Settings) that you DO NOT USE SPACES. If you have "http, net.tcp" instead of "http,net.tcp" it will not work, and instead give you this exact error.

More information here: http://www.weeksofprogramming.com/post/Could-not-find-a-base-address-Check-for-spaces-in-IIS7.aspx

like image 20
Kellen Avatar answered Sep 23 '22 19:09

Kellen