3

I'm designing an MVC application.

I'm considering using webservices so that multiple deployments of the MVC front end can work off a central database accessed via webservices hosted on a seperate server from the MVC application e.g.

  1. MVC application on one server
  2. Webservices implementing business logic and calling database on another server
  3. A database server

If I go down this route then

  1. The controllers in the MVC app will call the webservices, rather than the database directly

However I'm concerned that under this setup the models in the MVC project will just be placeholder objects with validation attributes in them and I will be missing out on other benefits/cabilitiues of the model.

Are there ways of aligning MVC applications with WCF so that using WCF dosn't mean you lose any of the benefits of MVC

2
  • What benefits are you afraid of losing? What's wrong with the MVC project having placeholder objects with validation attributes? What other benefits does the model provide? Commented Jul 29, 2011 at 10:41
  • Kierem, I'm basically worried that In my ignornace I've overlooked anything at the model side. Commented Jul 29, 2011 at 10:47

3 Answers 3

4

There are conceptually 3 models, though because the tools let us, we often use the same model throughout.

Using WCF does make Separation of Concerns explicit.

There's an Entity Model that defines the physical representation of data in your data store, such as that generated by EF. This is implementation specific.

There's a View Model that represents data in your UI. This is implementation specific.

There's a Domain Model that repesents data logically. This is used as the interface to your WCF services and is not implementation-specific. This allows, for instance, none-.NET clients to consume your services.

It's true that there is a code overhead, but in none-trivial cases, the benefits of further abstraction can be significant.

It allows you to change the implementation of your data access and the implementation of the UI independently and is a good thing.

Sign up to request clarification or add additional context in comments.

Comments

0

You are not loosing any benefit. It is about separation of concerns - you are doing that.

Comments

0

Right click the project in the Solution Explorer Choose Add–> Service Reference –> Then click the Advanced Button... –> Then click the "Add Web Reference…" button –> then type the address of your Web Service into the URL box. Then click the green arrow and Visual Studio will discover your Web Services and display them.

How to access a WCF service in an ASP.Net MVC application

3 Comments

Is this an answer or a question? Is the last sentence supposed to be a link?
this is aswer how to add mcf service in mvc appliction ,last Sentence (Url)
this is aswer how to add mcf service in mvc appliction ,last Sentence (Url) Is Url of Serive When We create Srvice Url Create auto According to Loacal :Local Host Like(localhost:XXX/Service1.svc)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.