Self-hosting 2,000+ web services through WCF

I am looking for a way to show many (2000+) similar web services through WCF.

I am working on an enterprise application in which business logic is packaged through classes (CQS). These classes make up all the data needed to execute a specific part of the business logic. I would like to find a way to expose these classes as web services using my own hosting.

All these classes have only one action (perform). All of them inherit from the base class, and their properties differ for each class. Based on the implemented interface and properties, the correct business logic is executed. Web services must be able to provide property values ​​and perform an action.

No more than 5% of them will be used regularly. I know that it is not possible to create 2000+ service host instances. This is not a problem if these host instances are created on demand and destroyed after, for example, 10 minutes of inactivity. Ideally, I will respond to a request from the client and create a host instance if necessary.

EDIT:
From the reactions, I understand that what I'm mostly looking for is a way to not register all endpoints. I believe that the most acceptable approach is that I myself listen to incoming requests and deploy hosts as needed.

Is it possible?

+4
source share
3 answers

Why not have a main service that has a request / response architecture, so that you only have one web service, but with many request methods or types? You can do this as a plugin architecture using MEF or something else. He can unwrap things as needed and close them when not. It also reduces the area of ​​your network.

+2
source

If I do not understand what you wrote. Do you have 2000+ services that implement a common basic service contract?

Could you then use dependency injection to serve the correct specific service bases on the requested specific interface?

This way you provide a single host, but create your own instance provider, which uses the requested ServiceType to redirect the request to the correct instance type.

It seems to be WCF DI or Switchable WCF service but not really.

+1
source

I do not understand why you need more than one endpoint. For each of your command classes output one operation:

[OperationContract] void ExecuteClassACommand(ClassA command) { command.Execute(); } 

You can then automatically generate operations each time you add or remove command classes.

+1
source

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


All Articles