Web API vs Web Service C#
In programming world, OPPS become so popular due to its reusibility and other important features what we had discussed in OOPS Concept.
So, if we need to create any method in a class which can be accessible
inside another classes as well so it must be public
. And if we need to make any method of a class accessible for whole world (of course by different
plateform and different application) then we must keep it over internet
and this is called Web Service
.
So, Web Services is a application/program which are available/accessible over internet.
Web Services in C#
A Web services
are any bit of services/HTTP Service
) that makes it accessible over the Internet and normalizes its correspondence through XML encoding.
Web services are equivalent to SOA (Services Oriented Architecture) and fundamentally depend on measures, for example, XML-RPC
and SOAP (Simple Object Access Protocol)
.
Components Of Web Services
A standard web services work using the following components.
We'll discuss in details about Web Service in another article.
Web API in C#
An API is some kind of interface/application which has a set of functions that allow programmers to access specific features or data of an application, operating system or other services.
Web API as the name suggests, is an API over the web
which can be accessed using HTTP protocol. Please keep in mind that Web API is a concept
and not a technology
It is used to create RESTful web services. REST stands for Representational State Transfer
, which is an architectural style for networked hypermedia applications.
It is primarily used to build Web Services that are lightweight, maintainable, and scalable, and support limited bandwidth.It is used to create a simple HTTP Web Service. It supports XML
,
JSON
, and other data formats.
Why Web API if Web Service was already there?
For this question I have a simple answer- all web services are APIs, but not all APIs are web services
.APIs and web services are not mutually exclusive. In fact, one is a subset of the other:
every web service is an API — since it exposes an application’s data and/or functionality — but not every API is a web service.
Web API vs Web Service in C#
Both web services and APIs are — at their core — very useful and very much used today but there are some differences between them are:
HTTP
protocol whereas API supports HTTP/HTTPS
protocol.Summary
To summarise, APIs are application interfaces, meaning that one application is able to interact with another application in a standardized way. Web services are a type of API, which must be accessed through a network connection. Hope you picked up a thing or two.
Cheers!