Saw some web applications working with WCF services.

  1. When is this practice justified?
  2. Does MVC have any weaknesses that cover WCF? Or everything can be implemented in Web applications, and using WCF is personal preferences and convenience issues?

For example, I saw that work with the database was carried out in WCF.

  • WCF should be used if some of its specific features are required, such as distributed transactions, duplex connections, MSMQ, message-level security, various transport protocols (not just http), etc. - kmv

1 answer 1

As far as I understand, you are talking about multi-layered architecture. There is an approach in which the browser accesses the web server, the web server accesses the backend, and the backend accesses the database.

This separation should be used when

  1. first, your application has an event-oriented architecture, and a common database is not enough for the application components to communicate with each other;
  2. secondly, you have several of these components that need to communicate with each other.

There are two scenarios for the appearance of a similar layer:

  1. A component appears in the application, which should work independently of user requests. For example, some timer, periodically referring to other services on the Internet. It turns out that he should receive information from users immediately, and not by periodically re-reading the database.

    After that, this component appears WCF-interface. And then the architect decides that it is easier to transfer all the work from the database to this component than to solve problems with races and distributed transactions.

  2. The application should be scaled horizontally (put a second web server), but it has a component that should be common to all sessions (for example, something SignalR-like). This component is placed in a separate background service, and the interface to it remains in the web application. Further work with the base moves to the same component in order to avoid races and distributed transactions.

Well and, of course, such a layer may appear in advance if the architect expects the possibility of such a situation in the future. Usually in this case, the developers have questions "why is there an extra layer".


If it was about the Web WCF service, which is working from javascript, then this is just a weighty legacy of the past. Modern people for these purposes use ASP.NET WebApi.

If the web service is in the MVC project, but no client script works with it, this is a form of an external API for integration with other systems or subsystems (see SOA, service-oriented architecture).

  • , is it possible to learn more about "WCF Web service with which javascript is working"? Why was this done in its time? If there is a script on the page that polls the readiness check WCF method from time to time, and if “Ready” returns, then the download icon on the page changes to ready, does this apply to the described case? - iluxa1810
  • No idea why this was done. - Pavel Mayorov