Implement service layer in MVC
Posted
by
Dan H
on Programmers
See other posts from Programmers
or by Dan H
Published on 2012-12-07T15:25:37Z
Indexed on
2012/12/07
17:34 UTC
Read the original article
Hit count: 436
We have a defined service layer hosted in WCF. We are now building a website that will need to use the services functionality. The website is being written in ASP.NET MVC 4 and I'm trying to decide how to reference the WCF service from the MVC app. It's a large complex website and it will be changing on a weekly basis.
My first reaction is to abstract out the service references (About 7 services on this one WCF host) and create a service ref facade library with which the website interacts.
But, I don't know exactly how to use the service facade in MVC. I'm starting to think the Models will be responsible for it because when the controller gets a model, that model should call the service (if needed) and return what the controller asked. I'm trying to avoid having the MVC app know details of the service references. So, I could have a model factory that creates whatever model the controllers need and they can use the service facade to accomplish it.
Is this a good plan, or am I off track?
© Programmers or respective owner