开发者

new ServiceHost for every WCF service?

First,Im running a windows service that should contain a lot of funcionality.There will be a business layer and the results comming from this business layer will be sent over WCF to the presentation layer.

I dont know how to structe all this functionality.

So my questions are :

1. Should I create somekind of a Facade pattern class that will cover all the service classes and put this one Facade Class to one ServiceHost. Or just create a ServiceHost instance for every service class?? Like this

host1 = new ServiceHost(typeof(MyService1));
host2 = new ServiceHost(typeof(MyService2));

2.How granular should be my service classes? Per enitity or per aggregate root or per some functionality block ?

This communication will run over net.pip开发者_开发技巧e.


There's an example of running multiple service hosts under a single windows service here: http://thegrenade.blogspot.com/2009/08/hosting-multiple-wcf-services-under.html

And a related question here: Can you host multiple WCF processes in a single windows service?


Let your interfaces be your guide. Define the interfaces you plan to expose through WCF. This will define how many service classes you need, and consequently, how many ServiceHost instances you need.


One ServiceHost can only host a single service (implementation) class - that's a given, you can't change that.

But a service (implementation) class can implement any number of service contracts (interfaces).

However, living up to the separation of concerns principle, I don't see a lot of compelling reasons to have a humongous "SuperDuperServiceClass" which implements a boat load of service contracts - I like to keep things that have nothing to do with one another separate - makes it easier to manage it in the long run.

What's your reasoning against having a single service host for a single service?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜