Is it possible to create an other endpoint in HTTP on the same port?

348 views Asked by At

One of my mate has created a C# WCF service working on Net.TCP on a specific port, it is asked to me if it is possible to create an other endpoint on this WCF service in order to consume it with HTTP protocol on the same port ?

How can I do to consume a WCF service with two differents protocols Net.TCP + HTTP ?

Thanks per advance for your answers :)

Edit : Do you have an example about how to implement a HTTP + Net.TCP endpoints in a WCF service ?

1

There are 1 answers

2
Abraham Qian On

As far as I know, this is completely impossible. But service could work properly over Net.TCP+Http over different port number.

<services>
      <service  name="ConsoleApp3.TestService">
        <endpoint address="" binding="netTcpBinding" contract="ConsoleApp3.ITestService" ></endpoint>
        <endpoint address="http" binding="basicHttpBinding" contract="ConsoleApp3.ITestService"></endpoint>
        <endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange"></endpoint>
        <host>
          <baseAddresses>
            <add baseAddress="net.tcp://localhost:21012"/>
            <add baseAddress="http://localhost:21013"/>
          </baseAddresses>
        </host>
      </service>
</services>

Net.TCP Port sharing only is applicable for the scenario that has different service addresses, not the indeed port sharing.
Feel free to let me know if there is anything I can help with.