tags:

views:

42

answers:

2

Hello,

How do I use multiple contracts with the same binding on the same port through C# code?

Would appreciate any simple code snipplet...

Thanks so much

A: 

I'm afraid there is no "simple code snippet" for this. Use the following article to get started and just add more ServiceHost objects: http://msdn.microsoft.com/en-us/library/ms733069.aspx

If you haven't already, it would be wise to get a book on WCF.

Bernard
A: 

What about this:

public class Service : IServiceContract1, IServiceContract2
{
  ...
}

Configuration (can be easily rewritten to code if you add Endpoint instances to ServiceHost by calling AddServiceEndpoint)

<services>
  <service name="Service">
    <host>
      <baseAddresses>
        <add baseAddress="http://localhost:8888/Service" />
      </baseAddresses>
    </host>
    <endpoint address="first" binding="basicHttpBinding" contract="IServiceContract1" />
    <endpoint address="second" binding="basicHttpBinding" contract="IServiceContract2" />
  </service>
</services>
Ladislav Mrnka
what would be the base address if I need to include a TCP endpoint?
Josh
For TCP endpoint use address with net.tcp:// scheme.
Ladislav Mrnka