Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Design Choice: WCF or Service Stack?

I have three core applications that have their own business functions (networks, active directory and helpdesk). Each are running ASP.NET v2 or v3 and have their own respective databases. However, the application functions have merged a bit so models were recreated in each application and app logic along with it. So now I have some difficult to maintain code. So here is my question:

  1. Is porting my models and repositories over to WCF a reasonable choice for this type of architecture?

  2. Is using a service stack such as serialized json calls a better choice? I'd imagine this would be faster than setting up a central wcf app.

I'm not too familiar with communication between asp.net mvc web apps so please point me in the right direction.

like image 940
Jiminy Avatar asked Nov 14 '22 10:11

Jiminy


1 Answers

I would recommend developing a service layer per the design pattern described by Fowler. This service layer encapsulates the various domain models and repositories and handles interactions between different domains/models. This will be an assembly and not a WCF or any other type of web service. If you require a WCF web service then it will be a very thin layer which basically has a contract that mimics the service layer and only purpose is to provide a web service interface or API.

There are a couple of ways an MVC application can interact with your service layer. If you are creating view models in your Controllers then it can access the service layer assembly directly. There is added overhead to calling it through a web service that is most likely not necessary in this case. Using this approach the service layer is pretty much your Model in the MVC trio.

The other way to access the service layer is from the Views/client using AJAX for rich clients. In this case you would use MVC to put a REST API on top of your service layer so that you can make AJAX POST's, using something like JQuery, directly to the web service to update and retrieve data for the web page.

Note with this architecture you can use a combination of both approaches. You may access the service layer directly from the Controller to render some initial pages and then use the web service REST interface for AJAX calls during user interaction.

like image 192
Kevin Junghans Avatar answered Dec 20 '22 02:12

Kevin Junghans