简体   繁体   English

ADO.NET/WCF DataService的项目设置

[英]Project setup for an ADO.NET/WCF DataService

I'd like to implement a ADO.NET/WCF DataService and I am wondering what's the best way to setup a project in VS2008 SP1 for this purpose. 我想实现一个ADO.NET / WCF DataService,我想知道在VS2008 SP1中为此目的设置项目的最佳方法是什么。

Currently I have an ASP.NET web application project (not of "WebSite" project type). 目前我有一个ASP.NET Web应用程序项目(不是“WebSite”项目类型)。 The data access layer is an Entity model (EF version 1) with SQL Server database. 数据访问层是具有SQL Server数据库的实体模型(EF版本1)。 I have the Entity Model in a separate DLL project and the web application project references to this assembly for all data accesses. 我在单独的DLL项目中有实体模型,Web应用程序项目引用此程序集以进行所有数据访问。

The ADO.NET/WCF DataService needs to communicate with the Entity model/database as well. ADO.NET/WCF DataService也需要与实体模型/数据库通信。 It has to be hosted on the same web server (IIS 7.5) together with the web application. 它必须与Web应用程序一起托管在同一Web服务器(IIS 7.5)上。

Since the DataService is not directly related to that specific web application (though it will provide and modify data from/in the same database the web application uses as well) my basic idea was to separate the DataService in its own new project (which also references the Entity Model DLL). 由于DataService与该特定Web应用程序没有直接关系(尽管它将提供和修改Web应用程序使用的同一数据库中的数据),我的基本想法是将DataService分离到自己的新项目中(这也是引用实体模型DLL)。

Now I have seen that there is no project type "ADO.NET/WCF DataService" in VS2008 SP1. 现在我已经看到VS2008 SP1中没有项目类型“ADO.NET/WCF DataService”。 It seems only possible to add a DataService as an element to other existing projects, for instance Web Application projects. 似乎只能将DataService作为元素添加到其他现有项目,例如Web应用程序项目。

Why isn't there a separate DataService project type? 为什么没有单独的DataService项目类型? Does this mean now that I have to add the DataService as an element to my Web Application project? 这是否意味着我必须将DataService作为元素添加到我的Web应用程序项目中? Or shall I create a new Web Application project and add a DataService to it? 或者我应该创建一个新的Web应用程序项目并向其添加DataService? (I could delete the pregenerated default.aspx since I do not need any web pages in this project.) What's the best way? (我可以删除预生成的default.aspx,因为我在这个项目中不需要任何网页。)最好的方法是什么?

Thank you for suggestions in advance! 提前感谢您的建议!

Since you are hosting your WCF services, you should use a Web Application Project for it. 由于您要托管WCF服务,因此应该使用Web应用程序项目。 It can be hosted on a seperate site in IIS, where you can connect to using different web applications. 它可以托管在IIS中的单独站点上,您可以在其中使用不同的Web应用程序进行连接。 There is no need for a seperate WCF DataService Project Template. 不需要单独的WCF DataService项目模板。

You get the following references like this: 你得到以下这样的引用:

Website --> WCF Service Website --> EM 网站 - > WCF服务网站 - > EM
Project (for the model) 项目(模型)
WCF Service --> EM Project WCF服务 - > EM项目

I believe this article ( http://msdn.microsoft.com/en-US/library/cc668805.aspx ) gives some important hints to the question. 我相信这篇文章( http://msdn.microsoft.com/en-US/library/cc668805.aspx )给出了一些重要提示。 Especially the following quote might give the explanation why there is no separate project template for WCF DataServices: 特别是以下引用可能会解释为什么WCF DataServices没有单独的项目模板:

ADO.NET Data Services are not standalone network services. ADO.NET数据服务不是独立的网络服务。 An ADO.NET Data Service does not bind to and listen on a network socket for incoming requests to its representational state transfer (REST) entry points. ADO.NET数据服务不会绑定并侦听网络套接字,以获取其表示状态传输(REST)入口点的传入请求。 Instead, an ADO.NET Data Service is a component hosted in an environment such as the Windows Communication Foundation (WCF) that provides core server networking facilities. 相反,ADO.NET数据服务是托管在诸如Windows Communication Foundation(WCF)之类的环境中的组件,它提供核心服务器网络设施。 The host handles direct interactions with the network and support caching, scalability, and authentication modules. 主机处理与网络的直接交互,并支持缓存,可伸缩性和身份验证模块。

And the options to host a WCF DataService in a project seem to be: 在项目中托管WCF DataService的选项似乎是:

  • ASP.NET application ASP.NET应用程序
ADO.NET Data Services can be hosted as a WCF endpoint inside an ASP.NET application. ADO.NET数据服务可以作为ASP.NET应用程序内的WCF端点进行托管。 In this implementation, WCF and ASP.NET handle the network interaction for an ADO.NET Data Service. 在此实现中,WCF和ASP.NET处理ADO.NET数据服务的网络交互。
  • or WCF ServiceHost or WebServiceHost 或WCF ServiceHost或WebServiceHost
ADO.NET Data Services can be hosted using the WCF ServiceHost or WebServiceHost classes. 可以使用WCF ServiceHost或WebServiceHost类托管ADO.NET数据服务。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM