Click here to Skip to main content
15,888,521 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have WCF Services exposed by dynamics CRM 2011, and a ASP.NET MVC3 portal to consume these services.

I have to make call to WCF services from controller and I don't want to make call to WCF services directly from controller. I can think of following patterns

•Service Facade

•DI and IoC at controller level


What is the best practice in terms of patterns for this scenario.

Thanks
Posted

1 solution

Hi! In general, accessing web (or WCF) services should be encapsulated by the Model part of the MVC pattern. Since ASP.NET MVC does not prescribe rules of how your model classes should be organized, you have to make those decisions by yourself. Make your model classes expose interface(s) that will be consumed by MVC controllers. Those interfaces can be the contracts of CRM services themselves, or something different, depending on your situation -- they will be the Service Facade that you mentioned. Use IoC/DI to let MVC controllers obtain object instances for the interfaces. And (just to make sure): AsyncController should be used in this scenario. That's it. Please feel free to follow up with any additional questions.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900