1

I'm trying to do multiple endpoints for a single WCF Service, so that each endpoint has its separate interface / methods. I'm using TCP

app.config:

<configuration>
  ....
  <system.serviceModel>
    <services>
      <service name="WCFLibrary.CalculatorService">
          <host>
            <baseAddresses>
              <!--<add baseAddress="http://localhost:8788/CalculatorService/" />-->
              <add baseAddress="net.tcp://localhost:8523/CalculatorService" />
            </baseAddresses>
          </host>
          <endpoint name="ServiceTCPEndPoint" 
              address="" 
              binding="netTcpBinding" 
              contract="WCFLibrary.ICalculator">
            <identity>
              <dns value="localhost" />
            </identity>
          </endpoint>
          <endpoint name="ServiceMexEndPoint" address="mex" binding="mexTcpBinding" contract="IMetadataExchange" />
      </service>
      <service name ="WCFLibrary.MyWorldService">
        <host>
          <baseAddresses>
            <add baseAddress="net.tcp://localhost:8524/MyWorldService"/>
          </baseAddresses>
        </host>
        <endpoint name="HelloWorldTCPEndpoint" 
            address="" 
            binding="netTcpBinding" 
            contract="WCFLibrary.MyWorld">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint name="HelloWorldMexEndPoint" 
            address="mex" 
            binding="mexTcpBinding" 
            contract="IMetadataExchange" />
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <serviceMetadata/>
          <serviceDebug includeExceptionDetailInFaults="True" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
</configuration>

My first endpoint is working, but my second endpoint doesn't work. What could be wrong here. Secondly why can't we browse tcp, like we can do for HTTP. I know we can test tcp using svcutil. Is there anyway to browse TCP.

EDIT:

WCF:

http://pastebin.com/gHHRKeYZ

WindowsService:

http://pastebin.com/kjM3iRYj

user726720
  • 1,127
  • 7
  • 25
  • 59
  • The second endpoint contract attribute value is "WCFLibrary.MyWorld" Just wanted to confirm if that is the correct interface? – Rajesh Aug 07 '14 at 15:27

2 Answers2

2

All net.tcp endpoints should use the same port using port sharing.

There are several articles/tutorials in MSDN and else where on how to achieve this. Here is one

Try this config settings

<system.serviceModel>
<bindings>
  <netTcpBinding>
    <binding name="tcpDefault" portSharingEnabled="true" />

  </netTcpBinding>
</bindings>
<services>
  <service name="WCFLibrary.CalculatorService">

      <host>
        <baseAddresses>
          <!--<add baseAddress="http://localhost:8788/CalculatorService/" />-->
          <add baseAddress="net.tcp://localhost:8523/CalculatorService" />
        </baseAddresses>
      </host>
      <!-- Service Endpoints -->
      <!-- Unless fully qualified, aBddress is relative to base address supplied above -->
      <endpoint name="ServiceTCPEndPoint" address="" binding="netTcpBinding" bindingConfiguration="tcpDefault" contract="WCFLibrary.ICalculator">
        <!-- 
          Upon deployment, the following identity element should be removed or replaced to reflect the 
          identity under which the deployed service runs.  If removed, WCF will infer an appropriate identity 
          automatically.
      -->
        <identity>
          <dns value="localhost" />
        </identity>
      </endpoint>
      <!-- Metadata Endpoints -->
      <!-- The Metadata Exchange endpoint is used by the service to describe itself to clients. -->
      <!-- This endpoint does not use a secure binding and should be secured or removed before deployment -->
      <endpoint name="ServiceMexEndPoint" address="mex" binding="mexTcpBinding" contract="IMetadataExchange" />
    </service>
  <service name ="WCFLibrary.MyWorldService">
    <host>
      <baseAddresses>
        <add baseAddress="net.tcp://localhost:8523/MyWorldService"/>
      </baseAddresses>
    </host>
    <endpoint name="HelloWorldTCPEndpoint" address="" binding="netTcpBinding"  bindingConfiguration="tcpDefault" contract="WCFLibrary.MyWorld">
      <identity>
        <dns value="localhost" />
      </identity>

    </endpoint>
    <endpoint name="HelloWorldMexEndPoint" address="mex" binding="mexTcpBinding" contract="IMetadataExchange" />
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior>
      <!-- To avoid disclosing metadata information, 
      set the values below to false before deployment -->
      <!--<serviceMetadata httpGetEnabled="False" httpsGetEnabled="False" />-->
      <serviceMetadata/>
      <!-- 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="True" />
    </behavior>
  </serviceBehaviors>
</behaviors>

Satish
  • 3,020
  • 7
  • 35
  • 47
  • This didnot work as I intended. I have two different interfaces, pointing to two different callbacks. Now how should configure the endpoints – user726720 Aug 01 '14 at 07:50
  • I'm not sure what you mean. You still have 2 different endpoints with 2 different interfaces. It just that they both are hosted on the same port number. You will still be able to call both seperately using the complete url net.tcp://localhost:8523/CalculatorService/Calulator.svc and net.tcp://localhost:8523/MyWorldService/WorldService.svc – Satish Aug 01 '14 at 13:56
  • I'm not able to download the metadata after it hosted in a windows service, using svcutil – user726720 Aug 01 '14 at 15:27
  • Did you enable Port Sharing Service on windows http://msdn.microsoft.com/en-us/library/ms733925(v=vs.110).aspx ? – Satish Aug 01 '14 at 20:03
  • yes thats enabled from service manager, i believe there is something wrong in the hosting, but im not able to figure this out – user726720 Aug 02 '14 at 07:21
1

If you are using @Staish configuration, you can try to uncomment this line in the service behaviour.

 <!--<serviceMetadata httpGetEnabled="**True**" httpsGetEnabled="False" />-->

Then you'll be able to use the svcutil to create the proxy.

You can comment it back before publishing if you want.

pposada
  • 108
  • 5