Marcin Seredynski
Marcin Seredynski

Reputation: 7157

WCF config for a service class implementing multiple contracts on separate endpoints

I have a MyService class implementing IService1 and IService2 interfaces. I would like to expose these two contracts on two separate endpoints, like:

How would such a config look like?

Upvotes: 1

Views: 670

Answers (2)

Nix
Nix

Reputation: 58522

Try this....

<services>      
  <service name="Service">
    <endpoint address="http://localhost:8080/Service/S1"
              binding="basicHttpBinding"
              contract="IService1"

     />

    <endpoint address="http://localhost:8080/Service/S2"
              binding="basicHttpBinding"
              contract="IService2 "

     />
  </service>
</services>

Upvotes: 3

Johann Blais
Johann Blais

Reputation: 9469

You can just use a service with two endpoints, like this:

<services>      
  <service name="MyNamespace.MyService">
    <endpoint address="/Service/S1"
              binding="basicHttpBinding"
              contract="IService1" />
    <endpoint address="/Service/S2"
              binding="basicHttpBinding"
              contract="IService2 " />
    <host>
      <baseAddresses>
        <add baseAddress="http://localhost:8080/"/>
      </baseAddresses>
    </host>
  </service>
</services>

EDIT: Added base address

Upvotes: 1

Related Questions