到ASP.NET MVC或RESTful或WCF REST服务

时间:2022-03-30 04:13:44

My client provides various data related to a consumers shopping habits in grocery stores based on their membership.

我的客户根据其会员资格提供与杂货店消费者购物习惯相关的各种数据。

One of their vendors wants to tap into the data and build an intranet site for the company. All my client is willing to provide is some form of web service so that the vendor could consume the data as they need and build their intranet site using that data.

他们的一个供应商希望利用数据并为公司构建内部网站点。我的所有客户都愿意提供某种形式的Web服务,以便供应商可以根据需要使用数据并使用该数据构建其Intranet站点。

What would be a recommended way to provide this data? 2.0 webservice or some sort of .NET REST service or WCF service?

提供此数据的推荐方法是什么? 2.0 webservice或某种.NET REST服务或WCF服务?

The data is stored on sql.

数据存储在sql上。

An example of a search, a hypothetical search could be to get data where consumers bought sugar and bought pie crust between certain dates which could result in 0..n records which need to be sent back to the vendor for their consumption.

一个搜索的例子,一个假设的搜索可能是获取消费者购买糖的数据,并在某些日期之间购买馅饼皮,这可能导致0..n记录需要被送回供应商消费。

4 个解决方案

#1


Although WCF is a simple way to get a rest service up, particularly if you are consuming it with a .net client, I prefer rolling my own services using ASP MVC.

尽管WCF是一种获得休息服务的简单方法,特别是如果你使用.net客户端使用它,我更喜欢使用ASP MVC来创建自己的服务。

It gives you much finer grained control over your resources. You can watch HTTP headers for authentication information, content types, etc or return custom HTTP status codes depending on the result of the action. You won't be constrained to the WCF conventions. You will have to do more manual work when consuming the services, but I feel that the end result is worth it.

它为您提供了更精细的资源控制。您可以查看HTTP标头以获取身份验证信息,内容类型等,也可以根据操作结果返回自定义HTTP状态代码。您不会受限于WCF约定。在使用服务时你将不得不做更多的手工工作,但我觉得最终结果是值得的。

#2


Not sure exactly what the requirements are, but you might also consider looking into ADO.NET Data Services : http://msdn.microsoft.com/en-us/data/bb931106.aspx

不确定要求是什么,但您也可以考虑调查ADO.NET数据服务:http://msdn.microsoft.com/en-us/data/bb931106.aspx

This framework can simplify adding RESTful access to relational data.. and return results in JSON, XML, etc..

该框架可以简化添加对关系数据的RESTful访问..并返回JSON,XML等结果。

#3


I think it really depends on what format you want to provide the data in. If you are thinking SOAP, then WCF is the way to go. If you want to provide XML or JSON, then you could do either WCF or MVC. If both ends are going to be .NET then a SOAP solution is probably ok. If there is a possibility of having to support other platforms from the service, then I'd look at using JSON or XML. My preference would probably be JSON/XML and MVC at this point just because the setup of WCF seems like overkill for a simple web service. Older style web services in .NET are being phased out in favor of WCF so I probably wouldn't go that route.

我认为这实际上取决于您想要提供数据的格式。如果您正在考虑SOAP,那么WCF就是您的选择。如果要提供XML或JSON,则可以执行WCF或MVC。如果两端都是.NET,那么SOAP解决方案可能没问题。如果有可能必须支持该服务的其他平台,那么我将考虑使用JSON或XML。我的偏好可能是JSON / XML和MVC,因为WCF的设置对于简单的Web服务来说似乎有些过分。 .NET中的旧式Web服务正在逐步淘汰,以支持WCF,因此我可能不会采用这种方式。

#4


If you do not need to reuse the web service in other application, I would suggest ASP.NET MVC. It is quite easy to serialise data in JSON format in ASP.NET MVC and consume it using jQuery.

如果您不需要在其他应用程序中重用Web服务,我建议使用ASP.NET MVC。在ASP.NET MVC中以JSON格式序列化数据并使用jQuery消费它非常容易。

#1


Although WCF is a simple way to get a rest service up, particularly if you are consuming it with a .net client, I prefer rolling my own services using ASP MVC.

尽管WCF是一种获得休息服务的简单方法,特别是如果你使用.net客户端使用它,我更喜欢使用ASP MVC来创建自己的服务。

It gives you much finer grained control over your resources. You can watch HTTP headers for authentication information, content types, etc or return custom HTTP status codes depending on the result of the action. You won't be constrained to the WCF conventions. You will have to do more manual work when consuming the services, but I feel that the end result is worth it.

它为您提供了更精细的资源控制。您可以查看HTTP标头以获取身份验证信息,内容类型等,也可以根据操作结果返回自定义HTTP状态代码。您不会受限于WCF约定。在使用服务时你将不得不做更多的手工工作,但我觉得最终结果是值得的。

#2


Not sure exactly what the requirements are, but you might also consider looking into ADO.NET Data Services : http://msdn.microsoft.com/en-us/data/bb931106.aspx

不确定要求是什么,但您也可以考虑调查ADO.NET数据服务:http://msdn.microsoft.com/en-us/data/bb931106.aspx

This framework can simplify adding RESTful access to relational data.. and return results in JSON, XML, etc..

该框架可以简化添加对关系数据的RESTful访问..并返回JSON,XML等结果。

#3


I think it really depends on what format you want to provide the data in. If you are thinking SOAP, then WCF is the way to go. If you want to provide XML or JSON, then you could do either WCF or MVC. If both ends are going to be .NET then a SOAP solution is probably ok. If there is a possibility of having to support other platforms from the service, then I'd look at using JSON or XML. My preference would probably be JSON/XML and MVC at this point just because the setup of WCF seems like overkill for a simple web service. Older style web services in .NET are being phased out in favor of WCF so I probably wouldn't go that route.

我认为这实际上取决于您想要提供数据的格式。如果您正在考虑SOAP,那么WCF就是您的选择。如果要提供XML或JSON,则可以执行WCF或MVC。如果两端都是.NET,那么SOAP解决方案可能没问题。如果有可能必须支持该服务的其他平台,那么我将考虑使用JSON或XML。我的偏好可能是JSON / XML和MVC,因为WCF的设置对于简单的Web服务来说似乎有些过分。 .NET中的旧式Web服务正在逐步淘汰,以支持WCF,因此我可能不会采用这种方式。

#4


If you do not need to reuse the web service in other application, I would suggest ASP.NET MVC. It is quite easy to serialise data in JSON format in ASP.NET MVC and consume it using jQuery.

如果您不需要在其他应用程序中重用Web服务,我建议使用ASP.NET MVC。在ASP.NET MVC中以JSON格式序列化数据并使用jQuery消费它非常容易。