当要Web服务不能使用? [英] When should a web service not be used?

查看:126
本文介绍了当要Web服务不能使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Web服务通常是一个很好的架构方法。并且,随着WCF的.NET中的出现,它变得更好。

Using a web service is often an excellent architectural approach. And, with the advent of WCF in .Net, it's getting even better.

不过,以我的经验,有些人似乎认为,Web服务应始终调用数据库中的数据访问层中使用。我不认为Web服务是通用的解决方案。

But, in my experience, some people seem to think that web services should always be used in the data access layer for calls to the database. I don't think that web services are the universal solution.

我有几十个用户思考的小Intranet应用程序。 Web应用程序和Web服务部署到一台Web服务器,而不是Web场。还有就是不打算在未来能够使用这个特定的Web服务的另一个Web应用程序。在我看来,调用Web服务的成本不必要地增加了Web服务器的负担。有击中进程间的调用性能。维护和调试code为Web应用程序和Web服务更为复杂。所以,是的部署。我只是不明白在这里使用一个Web服务的优势。

I am thinking of smaller intranet applications with a few dozen users. The web app and its web service are deployed to one web server, not a web farm. There isn't going to be another web app in the future that can use this particular web service. It seems to me that the cost of calling the web service unnecessarily increases the burden on the web server. There is a performance hit to inter-process calls. Maintaining and debugging the code for the web app and the web service is more complicated. So is deployment. I just don't see the advantages of using a web service here.

人们可以通过创建Web应用程序的两个版本,有和没有Web服务测试,并做压力测试,但我没有这样做。

One could test this by creating two versions of the web app, with and without the web service, and do stress testing, but I haven't done it.

你对使用Web服务的小型网络应用程序的意见?其他任何场合Web服务是不是一个很好的架构选择?

Do you have an opinion on using web services for small-scale web app's? Any other occasions when web services are not a good architectural choice?

推荐答案

Web服务是数据访问的绝对可怕的选择。这是一吨的开销和复杂性,为几乎为零收益。

Web Services are an absolutely horrible choice for data access. It's a ton of overhead and complexity for almost zero benefit.

如果您的应用程序要在一台机器上运行,为什么否认它做过程中的数据访问调用的能力?我不是在谈论从UI code直接访问数据库,我说的是抽象的仓库走,但仍然包括其在运行的网站组件。

If your app is going to run on one machine, why deny it the ability to do in-process data access calls? I'm not talking about directly accessing the database from your UI code, I'm talking about abstracting your repositories away but still including their assemblies in your running web site.

有情况下,我建议你的Web服务(我假设你的意思的SOAP),但是这主要是针对互操作性。

There are cases where I'd recommend web services (and I'm assuming you mean SOAP) but that's mostly for interoperability.

该服务的粒度也是一个问题在这里。在SOA意义上的服务将封装的操作或业务流程。数据访问方法是这一进程的一部分。

The granularity of the services is also in question here. A service in the SOA sense will encapsulate an operation or a business process. Data access methods are only part of that process.

在换句话说:

  - someService.SaveOrder(order);  // <-- bad
    // some other code for shipping, charging, emailing, etc

  - someService.FulfillOrder(order);  //<-- better
    //the service encapsulates the entire process

有关Web服务的缘故Web服务是不负责任的节目。

Web services for the sake of web services is irresponsible programming.

这篇关于当要Web服务不能使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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