Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When should a web service not be used?

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

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.

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.

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.

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?

like image 940
DOK Avatar asked Oct 15 '08 13:10

DOK


People also ask

Why you would use web service in a web page?

Web services enable any-to-any integration, supporting any programming language, any runtime platform, and any network transport. Technologies such as SOAP and WSDL are simpler to use than traditional integration middleware technologies, and they offer much more flexibility.

What are web services used for?

Web services are XML-based information exchange systems that use the Internet for direct application-to-application interaction. These systems can include programs, objects, messages, or documents. A web service is a collection of open protocols and standards used for exchanging data between applications or systems.

What is the difference between a web service and an API?

There you have it: an API is an interface that allows you to build on the data and functionality of another application, while a web service is a network-based resource that fulfills a specific task. Yes, there's overlap between the two: all web services are APIs, but not all APIs are web services.

When should we use web services?

Web services are used for a variety of applications, but the most common is for reusing code and connecting existing programs. The web service method can help developers segment applications into components that can be used and reused for various needs.


1 Answers

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

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.

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

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.

In other words:

  - someService.SaveOrder(order);  // <-- bad     // some other code for shipping, charging, emailing, etc    - someService.FulfillOrder(order);  //<-- better     //the service encapsulates the entire process 

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

like image 92
Ben Scheirman Avatar answered Oct 13 '22 23:10

Ben Scheirman