tags:

views:

5

answers:

1

Hi I have taken a WCFService library in which I have defined multipled service contracts(interfaces) in separate cs files and implemented them separately. For example ..

[ServiceContract]

public interface IService1

{

[OperationContract]
string GetService1Msg();

}

[ServiceContract]

public interface IService2

{

[OperationContract]

string GetService2Msg();

}

I have defined above interfaces in separate cs files.Now I have implemented them separately as follows.

//this is Service1.cs file

public class Service1 : IService1

{

string GetService1Msg()

{

 retutn "Service1";

}

}

//this is Service2.cs file

public class Service2 : IService2

{

string GetService2Msg()

{

 retutn "Service2";

}

}

My intention here is to expose above two as two service contracts/interfaces outside. Now My question is how to define endpoints for these two service interfaces in app.config of this WCF Servicelibrary?

Thanks in advance

Padma

+2  A: 

This is basic configuration of two services exposed on Net.Tcp, each with one endpoint for data and endpoint for metadata:

<behaviors>
  <serviceBehaviors>
    <behavior name="Metadata">
     <serviceMetadata />
    </behavior>
  <serviceBehaviors>
</behaviors>
<services>
  <service name="Namespace1.Service1" behaviorConfiguration="Metadata"> 
    <host>
     <baseAddresses>
      <add baseAddress="net.tcp://localhost/Service1" />
     </baseAddresses>
     <endpoint address="" binding="netTcpBinding" contract="Namespace1.IService1" />
     <endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange" />
    </host>
  </service>
  <service name="Namespace2.Service2" behaviorConfiguration="Metadata"> 
    <host>
     <baseAddresses>
      <add baseAddress="net.tcp://localhost/Service2" />
     </baseAddresses>
     <endpoint address="" binding="netTcpBinding" contract="Namespace2.IService2" />
     <endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange" />
    </host>
  </service>
</services>

You still need some code to host your services.

Ladislav Mrnka
The endpoints described by you are good for me. But if I have to use http binding, then how can I define endpoints. Should I need to give separate urls for each service?
padmavathi