【发布时间】:2011-09-30 03:10:13
【问题描述】:
我刚刚开始使用 web.api 为我们现有的 asp.net mvc web 应用程序的移动版本公开数据的 WCF 服务项目。
到目前为止,我已使用此 WCF web.api getting started tutorial 来运行某些东西,并在 ServiceContract 中创建了虚假数据。
服务合同如下所示:
[WebGet(UriTemplate = "")]
public IQueryable<Workspace> Get()
{
//I want to use our existing service layer like this:
//WorkspaceService service = new WorkspaceService();
//service.ReturnAllWorkspacesByUsername("mary");
//this is fake data for testing
var workspaces = new List<Workspace>()
{
new Workspace() {Id = new Guid(), Title = "Implement WCF Web Services"},
new Workspace() {Id = new Guid(), Title = "Add APIs to WebService"},
new Workspace() {Id = new Guid(), Title = "Map Routes"},
new Workspace() {Id = new Guid(), Title = "Expose Resources"},
};
return workspaces.AsQueryable();
}
我想尽可能地使用现有的mvc应用程序,如何才能最好地使用现有的服务层和域模型,或者最好不要这样做?分开服务更好吗?
任何人都可以为我指出一些好的初学者教程吗?
谢谢, 启
【问题讨论】:
标签: asp.net asp.net-mvc wcf web-services wcf-web-api