New ServiceHost for each WCF service?

First, I run the Windows service, which should contain a lot of functionality. There will be a business layer, and the results coming from this business layer will be sent through WCF to the presentation layer.

I do not know how to structure all this functionality.

So my questions are:

1. Should I create somekind of the class of the class Facade, which will cover all classes of service and put this one class Facade on one ServiceHost. Or just create an instance of ServiceHost for each class of service? Like this

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

2. How should my service classes be granulated? By design or for the aggregate root or for some block of functionality?

This post will work through net.pipe.

+3
source share
3 answers

Here is an example of starting multiple service hosts under one Windows service here: http://thegrenade.blogspot.com/2009/08/hosting-multiple-wcf-services-under.html

And a related question: Can you host multiple WCF processes in the same Windows service?

+5
source

Let your interfaces be your guide. Define the interfaces that you plan to open through WCF. This will determine how many service classes you need, and therefore how many ServiceHost instances you need.

+1
source

ServiceHost () - , .

() () .

However, adhering to the principle of separation of interests, I see no good reason to have an extensive "SuperDuperServiceClass" that implements the load on boat service contracts - I like to keep things that have nothing to do with each other - simplifies their management in the long term.

What is your argument against having a single host for a single service?

+1
source

Source: https://habr.com/ru/post/1722456/


All Articles