I'm creating a c# Project with WCF Service, I use 3-Tiers Architecture.
I create my WCF Service as below :
namespace MyApp.WCFService
{
[ServiceContract]
public interface IServiceWCF
{
[OperationContract]
string SayHello(string who)
}
}
namespace MyApp.WCFService
{
public class ServiceWCF : IServiceWCF
{
public string SayHello(string who)
{
return "Hello" + who + "from Web Service";
}
}
}
This works great, but in my solution I had another project with methods.
I would like to know if it's possible to make my IServiceWCF Interface implement my methods from an other project, not in the WCF. Or should I copy my methods and paste it in the WCFService class ?
Sorry for my bad english, I'm not a native speaker!
Thanks for your help
Erm, interface can never
implement
any details. If you need to implement some concrete logic, maybe you'd want to use an abstract class instead? (or maybe just a regular class, if that makes sense)However, interfaces can inherit from other interfaces without any problem. Just make sure you reference the required .dlls and that your desired interfaces are publicly visible.
Of course. Add a reference to the other project in the WCF project, let the class in the other project implement the WCF interface and configure your service to use the OtherProject.Namespace.Class as service.