Click here to Skip to main content
15,916,693 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
We can implement web applications using class library to talk to database server, or to another application/APIs.

Then why we need web services??

What can be done in web services, which cannot be done in class library ??


What I have tried:

What can be done in web services, which can't be done in class library ??
Posted
Updated 3-Jan-19 22:04pm

APIs allow applications to interact with one another, and as a whole do not specify what communication medium or protocol is used.

A Web Service is basically a wrapper around an API which uses a computer network as the communication medium and generally uses the HTTP protocol.

All Web Services are APIs, but not all APIs are Web Services.
 
Share this answer
 
Adding to the existing solution provided, here's my take:

Class libraries will turn into Dynamic-link library (a.k.a DLL). All consuming clients will have to add the dll to their project to reference them. This is fine if you will be dealing with applications within your premise or domain. However, if there are other client applications that want to reference your class library then it's gonna be a pain in the butt because you have to ensure that they got the right version and the proper access to your dll. With Web Services, you can simply host them in public facing server where other client applications can have access to via HTTP.

The important difference between them is that if you are working on modern web applications that heavily relies on AJAX and JavaScript and you want to communicate with your data from the server, then a class library can't do that. One advantage of the Web Services is to be able to communicate with your data via AJAX calls.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900