Search This Blog

Friday, November 22, 2013

netTcp binding in WCF service hosted in IIS server

WCF nettcp binding with IIS.
Required config
1 Enable  TcpPortSharing from add and remove feature .net advance features of .net 4.5
2 enable tcp communication from services.

use the following config for WCF service

<system.serviceModel>
    <services>
      <service behaviorConfiguration="SampleCalculatorServiceTcpBehavior"
        name="WcfServiceTcpBinding.CalculatorService">
        <endpoint address="" binding="netTcpBinding" bindingConfiguration="portSharingBinding"
          name="SampleCalculatorServiceTcpEndPoint" contract="WcfServiceTcpBinding.ICalculatorService" >
          <identity>
            <dns value="localhost"/>
          </identity>
       
        </endpoint>
        <endpoint address ="mex" binding="mexTcpBinding" bindingConfiguration="" name="SampleCalculatorServiceMexTcpEndPoint"
          contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="net.tcp://localhost:808/CalculatorService.svc" />
          </baseAddresses>
        </host>
      </service>
    </services>
    <standardEndpoints />
    <behaviors>
      <serviceBehaviors>
        <behavior name="SampleCalculatorServiceTcpBehavior">
          <serviceDebug includeExceptionDetailInFaults="false"/>
          <serviceMetadata httpGetEnabled="false"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <bindings>
      <netTcpBinding>
          <binding name="portSharingBinding" portSharingEnabled="true"/>
      </netTcpBinding>
    </bindings>
    <serviceHostingEnvironment
      multipleSiteBindingsEnabled="true" />
  </system.serviceModel>