1

I have a Wcf Service project. system.serviceModel tag in my web.config is :

  <system.serviceModel>
    <bindings>
      <netTcpBinding>
        <binding name="RCISPNetTcpBinding" openTimeout="00:10:00" sendTimeout="00:10:00">
          <security mode="Transport">
            <transport clientCredentialType="Windows" protectionLevel="EncryptAndSign">
            </transport>
            <message clientCredentialType="Windows"/>
          </security>
        </binding>
      </netTcpBinding>
    </bindings>

    <services>
      <service behaviorConfiguration="RCISP.WcfServiceBehaviour" name="RCISP.WcfService.PersonWcfService">
        <endpoint address="PersonServices" binding="netTcpBinding" bindingConfiguration="RCISPNetTcpBinding"
          contract="RCISP.Common.ServiceContract.IPersonService" >
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <host>
          <baseAddresses>
            <add baseAddress="net.tcp://localhost:40003/"/>
          </baseAddresses>
        </host>
      </service>
    </services>

    <behaviors>
      <serviceBehaviors>
        <behavior name="RCISP.WcfServiceBehaviour">
          <serviceMetadata httpGetEnabled="false" />
          <serviceDebug includeExceptionDetailInFaults="false" />
          <serviceAuthorization principalPermissionMode="UseWindowsGroups" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>

I have a runtime error when I want create self-hosting for service.

    public class ServiceFactory : ServiceHostFactory
    {
       protected override ServiceHost CreateServiceHost(Type serviceType, Uri[] baseAddresses)
       {
          if (!IsInitialised) InitialiseService();
             return base.CreateServiceHost(serviceType, baseAddresses);
       }

    }

Message of Exception is :

Could not find a base address that matches scheme net.tcp for the endpoint with binding NetTcpBinding. Registered base address schemes are [http].

Why?

Ehsan
  • 3,431
  • 8
  • 50
  • 70

2 Answers2

2

You said you were self hosting the service (within your own process) but based on the code above I think you're trying to host it inside of a web application. If so Visual Studio's web server can not host a net.tcp end point. You'll need to set the project up to run under IIS. Please follow the instructions here .

If you are truly self hosting than you can leave the configuration exactly how you have it and spin up the service using the following code:

var host = new ServiceHost(typeof(Service1));
host.Open();
Joseph Pisano
  • 123
  • 1
  • 8
1

You need to add a protocol mapping to your configuration file to tell it what the "net.tcp" protocol is. Right after your <bindings> section add this:

<protocolMapping>
  <add scheme="net.tcp" binding="netTcpbinding"/>
</protocolMapping>    
Michael Edenfield
  • 28,070
  • 4
  • 86
  • 117