Web服务VS. ASPX页面:优点和缺点 [英] Web Service VS. Aspx Pages: Pros and Cons

查看:477
本文介绍了Web服务VS. ASPX页面:优点和缺点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们开发一个内部网络上承载一个ASP.Net Web应用程序。目前,我们有处理来自客户端的Web请求,并与我们的服务器进行交互的一些ASPX页面。我们开始我们的下一个主要版本的应用程序开发,并且我们决定架构。

We develop an ASP.Net web application that is hosted on an internal network. Currently, we have some ASPX pages that handle web requests from the client side and interact with our servers. We are starting development on our next major application version, and we are deciding on the architecture.

什么是使用ASPX页面相比,使用一个完全成熟的Web服务(这很可能是一个WCF服务)来处理HTTP请求之间的区别是什么?

What are the differences between using ASPX pages to handle http requests as compared to using a full blown Web Service (which would most likely be a WCF Service)?

在研究这个问题,我也接触过一些相关的帖子已经被适度帮助,看到<一个href=\"http://stackoverflow.com/questions/1845461/can-a-server-page-jsp-aspx-be-used-as-web-service\">here和<一个href=\"http://stackoverflow.com/questions/4123764/wcf-service-as-a-replacement-for-aspx-service\">here.我的一些主要差异的理解如下:

In researching this issue, I have come across a few related posts that have been moderately helpful, seen here and here. My understanding of some of the key differences are as follows:


  1. ASPX页面都在种,他们可以接受请求的限制。他们是严格的HTTP,而WCF服务可以有多个端点服务于多种协议(HTTP,TCP等)。

  2. WCF服务是由于ServiceContracts更具体的定义。这意味着,如果一个项目,使该服务的引用,他们知道在方法,使用和文档方面的期望是什么。一个ASPX页面更是一个免费为所有在接受包含方法和要求条款。

然而,根据这些概念,我的问题如下:

However, based on these concepts, my issues are as follows:


  1. 来支持不同的协议的能力是未来的打样和兼容性方面的一个很大的特点,但我们看到什么是真正的好处,如果我们目前的只有的使用它通过HTTP?交互

  2. 在我的previous参数线,如果我们只通过Web服务进行交互,做任何这些点真的有什么区别? HTTP请求不关心任何这些更精细的细节或合同的担保,只要方法调用只是工程。

  1. The ability to support different protocols is a great feature in terms of future proofing and compatibility, but what real benefit are we seeing if we are currently only using it to interact via HTTP?
  2. In line with my previous argument, if we are only interacting with the service over a web, do any of those points really make any difference? An http request doesn't care about any of those finer details or contractual guarantees so long as the method it calls "just works".

有什么我失踪?任何关键的好处是用一个服务?就个人而言,我支持Web服务架构。我喜欢具有柔性和良好定义的系统,该系统能够支持未来发展的想法。什么我基本上希望摆脱这种是很长的路要走给同事,并说这应该是x和yž原因的服务,我们可以看到A B C改进,这样做的。

Is there anything I am missing? Any key benefit to using a service? Personally, I support the Web Service architecture. I like the idea of having a flexible and well defined system that can support future development. What I am basically looking to get out of this is a way to go to a coworker and say "This should be a service for x y z reasons and we could see a b c improvements for doing so".

推荐答案

WCF(和较早的基于ASMX的Web服务)做了很多对你的序列化任务。您可以从方法返回的对象,而框架将这些对象序列化到正确格式的XML,并为客户提供的WSDL,使他们可以打电话给你的web服务的方法和明白他们在说什么了。

WCF (and the older asmx-based web services) do a lot of the serialisation tasks for you. You can return objects from methods, and the framework will serialise those objects into the correct format XML and provide clients with the wsdl so they can call your webservice methods and understand what they're getting back.

您的 的能做到这一点与Web (我打赌有PHP的负荷网络服务在那里),但你必须做的一切水暖自己。

You could do this with a web page (I bet there are loads of PHP "web services" out there), but you'd have to do all that plumbing yourself.

请求的类型就是WCF的法宝。 WCF有终点,让你分开调用从服务做什么服务的方法的概念。它只是一个更好的(虽然很多事情很复杂)架构,更好地分离这两个担忧。

The type of request thing is WCF-magic. WCF has the notion of "endpoints" that allow you to separate the method of calling the service from what the service does. It's just a better (though many thing very complex) architecture that better separates those two concerns.

我怀疑任何Web服务的性能瓶颈会选择使用ASMX,而不是WCF。在Web服务架构的性能损失几乎都是因健谈接口和/或非常大的对象/对象图。你让一个Web服务远程调用张女士使得WCF的速度与ASMX微不足道在大多数情况下的差异。 WCF是更灵活的设计,这是一个有效的理由选择它。 WCF确实使用较新的的DataContractSerializer 而不是axms使用了老的方法,按说这是一个有点快。我认为你必须扩展到相当多的用户看到一个有意义的差别虽然 - 你会更好找健谈接口和第一业绩不佳的数据库查询

I doubt the performance bottleneck of any webservice would be the choice to use asmx rather than WCF. The performance penalties in web service architecture are almost always due to chatty interfaces and/or very large objects/object graphs. The very fact you're making a remote call to a webservice makes the difference in speed of WCF vs. asmx insignificant in most cases. WCF is more flexible in design, which is a valid reason to chose it. WCF does use the newer DataContractSerializer rather than the older method employed in axms, and supposedly it's a bit faster. I think you'd have to scale to quite a lot of users to see a meaningful difference though - you'd be better off looking for chatty interfaces and poorly performing db queries first.

当然,如果有疑问 - 测量,然后再针对业绩不佳特定领域

Of course, if in doubt - measure first, then target specific areas of poor performance.

这篇关于Web服务VS. ASPX页面:优点和缺点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆