English 中文(简体)
Where to put the calls to WCF or other webservices in MVVM?
原标题:

I m building Silverlight applicaitions using Prism and MVVM.

When calling WCF services on your own server, or even external webservices like the Bing api, would this be done from the Model? or from the ViewModel, thus making the service the Model?

最佳回答

Yes. The View should only manage the transformation of data into user interface elements, the Controller should only orchestrate the interaction between views and model, and the remaining (business logic and data access, this one including calls to remote services) should be in the Model.

问题回答

Sorskoot,

For your scenario, I create a Services class that interfaces with WCF. My ViewModels then interface with service.

Also, with silverlight introducing Silverlight 4, you may want to create your own models and use converters to convert the WCF objects going into your app so you have a level of separation. Plus you can start utilizing features such as IDataErrorInfo, INotifyPropertyChanged.

Search on Cinch. It s not Silverlight compatible but will give you an idea of what I m referring too. Look at DataWrappers.





相关问题
IIS 6.0 hangs when serving a web-service

I am having issues with one of our web-services. It works fine on my development machine (win XP) whether I host it as a separate application or using cassini from Visual studio. Once I deploy on the ...

ASP.net web services

I am using a web service which sets the Thread.CurrentPrincipal object while logging in and soon later when another webmethod of the same web service accesses Thread.CurrentPrincipal, its different/...

Unity Container Disposing and XML Web Service

I am registering some wrapers over un-managed objects in container. How can I dispose of them at the end of the container s lifetime? Please bear in mind I have an XML Web service.

SharePoint : web service permission error

I have a sharepoint site, and I am calling a standard sharepoint web service. I create the web service request like this : wsDws.Url = this.SiteAddress + @"/_vti_bin/Dws.asmx"; When I use ...

热门标签