You are on page 1of 3

Microservices vs APIs

https://www.youtube.com/watch?v=WFtmCaqIjkA

https://www.youtube.com/watch?v=oTzNRv6X51o&list=PLhW3qG5bs-L9E2KV6vVdB-YTk-sRxmRAB

Web Service: It facilitates interaction between two machines over a network.


: A software system designed to support interoperable machine to machine
interaction over a network.

Web API: It acts as a interface between two different applications so that they can communicate with
each other.
: A set of routine, data structure, ,object classes, protocols provided by libraries ,operating
system service
to support the building of application.

**An API exactly defines method for one S/W program to interact with the other. An API generally
involves calling
functions from within a software program.
When this action involves sending data over a network, web services come in the picture. In case of web
application,
the API used is web based.
Example: Desktop application as spreadsheet and word document use VBA and COM based API which
does not invole web services.

**A web service is merely an API wrapped in HTTP. An API does not always need to be web based.

**An API can be exposed in a number of ways as COM object, DLL in C, Jar File in Java, XML and JSON
over HTTP.

** All Web services are API but vice versa is not correct.
** Web services uses three style: REST, SOAP and XML-RPC. API may use any style.

** Web services always needs a network for its operation but API does not.

**Web means http protocol, service means request/response, stateless protocol(send a request, receive
resposne and done)

Example: API
when you’re on a website, let’s say reading the news, and you see those little social media icons at the
top.
“Follow us on Facebook/Twitter/YouTube!” it says. Embedding social media plugins like this requires an
API.

Example: WebService
Oxford Dictionary API, in which you can send it a word, and it will reply with their meanings.

WSDL- Web Service Descriptive Language


UUID: Universally unique identifier

SOAP we Service: A web service which compiles to the SOAP web services specification is a SOAP web
service
 All Information must exchange in Xml format. Xml message have a defined structure
SOAP MESSAGE
 SOAP Message consist of : Envelop, Header, Body

RESTFUL Web Service: A web service which communicates/exchanges information between 2


application use REST principles is called a RESTful Web Services.

A resource representation is transferred between server and client.

 REST(Representational State Transfer) is an architectural style. It defines a set of


principles to be followed while designing a service for communication/data
exchange between 2 application.
 When these principles are applied while designing web services we get RESTful web
service
 Uniform Interface
o Resource: Everything is resource
o URI: Any resource can be accessed by a URI
o HTTP: make explicit use of HTTP methods
 HTTP contains below method
o POST – Create
o GET – Read
o PUT – Update
o DELETE -- Delate
 Stateless
o All client server communication are stateless
 Sever should not require to store the state of a session. If concept of
session is required then all information must be stored at client side
and sent with every request.
 This makes every request from client independent and a
complete entity in itself.
 Example: if a person is adding item to his cart on shopping website,
the state of the cart should be stored at client side only. This state
of cart has to be sent from client to server whenever required.
 Cacheable
o The data within a response to a request must be implicitly labeled as
cacheable or non cacheable. Server generates responses that indicate
whether they are cacheable or not to improve the performance by reducing
number of request
o Server does this by including .. Cache Control and Last Modified(date value)
In HTTPS response header.
o Client uses the Cache-control header to determine whether to cache the
resource (make local copy) or not.
 Layered System
o Layers can exist between client and server
 There can be many layer(intermediaries) between client and server.
These are HTTP intermediaries. Can be used fro message
translation, Proxies and Gateway
 Example- We use a layer (intermediary) that can cache a
response and store it for a hour. If a new request
comes from the client within a hr, cache response will be
sent from intermediary.
 Code on Demand

You might also like