What are the pros and cons of Web services in ASP.NET

With web services, you can reuse someone else’s business logic by using just a few lines of code. This technique is similar to what software engineers currently do with libraries of APIs, classes and components. The fundamental difference is that web services can be located remotely on another server and managed by another company.

Web services have the next key advantages:

Web services are simple – They can be easily supported on a wide range of platforms.

Web services are loosely coupled – The web service may extend its interface and add new methods without affecting the clients as long as it still provides the old methods and parameters.

–  Web services are stateless – There is no permanent connection between the client and the web service. When the client makes a request to a web service, the web service returns the result, and the connection is closed. This makes it easy to scale up and out to many clients and use a server farm to serve the web services. The underlying HTTP used by web service is stateless too.

Web services are firewall-friendly – Firewalls can pose a challenge for distributed object technologies. The only thing that almost always gets through firewalls is HTTP traffic on ports 80 and 443. Because web services use HTTP, they can pass through firewalls without explicit configuration.

New payment structures – The user of a web service can pay a subscription fee for using the service. Another possibility is a pay per view, or micro payment, model. A provider of a credit verification service, for instance, may charge per request.

Real-time interaction and collaboration – Web services enable real-time queries to remote data. An example is an e-commerce site selling hardware devices. The e-commerce site may hook up to a warehouse to get the number of items in stock in real time. This enables the e-commerce site to provide a better service.

Aggregated services – A web service may aggregate other web services. A typical example of an aggregated service is a comparative service giving you the best deal on products. Another type of service is one that groups related services.

 

Web services also have the following disadvantages:

They don’t have all the features of more complex distributed component technologies – Web services do not support bidirectional communication, i.e. the web server cannot call back to a client after the client disconnects.

They can be overkill and may introduce unnecessary overhead – when you want to share functionality between two .NET applications. In this case a much better approach is to create a class library assembly and use it in both applications.

They do not provide freedom – Web services do not give you the freedom to use different types of communication, proprietary .NET data types, stateful objects, and  faster TCP/IP communication.