Web Services & Architecture Styles
Tags: beginners, tutorial, webdev, architecture
Published: 2020-01-08 12:55:09

###<strong><b>WEB-SERVICES</b></strong>
The service offered by the components which can be invoked or used to invoke the other components over the Inter-network.

#####Web Service Implementation methods:
            1. Using Remote procedure(RPC) 
            2. Using Service-oriented-architecture(SOA).
            3. Using Representational State Transfer(REST).
            4. Using Application Programme Interface(API).
###More About the Service:
In the typical Client-Service architecture model, where client requests and the server responds, the ***same*** happens here in the services. Where one component(service requestor) would request an object and client(service responder) object would respond with success/failure.


***Service Provider:***
From where the required services can be caught with the Invocation if it has, through the service broker/service repository/service registry. It responds if it has if it doesn't then it invokes other service provider and get the objects.

***Service Requestor:***
Service requestor requests the required services and makes the resources avail to the components through the series of communications. The communication between the Service requestor and the Service Provider would happen through the Service repository/Service registry. It is called Service consumer as it consumes the services from the Service Provider.

***Service Broker:***

These types of services act as an intermediary component between the Service Requestor and the Service consumer. Sometimes when the Service Provider doesn't have the resources asked by the Service consumer, then the present Service consumer would request the corresponding resources for other service providers. 

Example:
Let us assume Service requestor(SR1) has requested through the service broker(SB1) to the service provider SP1, but the service provider (SP1) doesn't have the corresponding resources. So now the SP1 would request the same resources to another service provider(SP2) in the name of service requestor(SR2) to the SP2 through the same/other service broke. At the same time, here SP1 is a service broker to the SR1. Eventually, It may continue as long as the resource is available. After the resource is found at SP[n]. It would return the same result to the service requestor(SR1) which might resemble Peer-to-Peer style. 

And Hence the same component might act as a service requestor as well as the service provider/service broker.

###Few of the ARCHITECTURE STYLES:
      Basic Architecture styles in order:
      1.Client-Server
      2.Peer-to-Peer
      3.Monolithic
      4.Service-Oriented
      5.Micro Services

***Starting from the First***
####Client-Server
As stated above the Server is the resources provider while the client is the one who would access them. Many clients would request the same/different resources and the server shall serve all the client requests. A client can access the files from the remote as well.
![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/s5xh8gj6296x39n3ca9p.jpg)
####Peer-to-Peer
All the systems(Nodes) would be collectively made network and share the files among them, whenever required. Each node can access common files and folders. The sharing is done through the medium of cable, Optical fibre.
Every node has the same processing power and Equipotent. 

####Monolithic 
The software is made upon the single and only one module. All the features and tasks will be done through the same module. Whenever the changes required to make then, the same module need to be changed and deployed the same.While the modularity of the modularity programming style is very thin. It can be compared to the analogy of the Solo player playing the game.

***New Generation Architectures:***
####Service-Oriented
Encapsulating all the application logic within a few components and share them as the services among them with the common protocols such as Simple Object Access Protocol(SOAP), and the messages can be exchanged with the XML.
Each of the Component in the SOA may have specific functionality and SOAP is the protocol used to convey the messages between the components and  HTTP protocol is used to access the application at the higher level of communication between the applications. While the Web Service Description Language(WSDL) is used in the SOA to describe the services available to other components so other components can access them. But the Implementation particulars of the services in the components are not represented in the WSDL, but to be done in the XML. In between Universal Description Discovery and Integration(UDDI) is used to describe the description, integration of the web services. 
It acts as the index of the web services available in the Web. It can be compared to the Phone Directory where all the services and the contacts are available. 

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/hw3ylvfckr0r7jrc6zr5.png)

A minute Issue to be discussed in the SOA is the communication between the applications of different types which are made of different programming languages an incompatibility issue is araised. This incompatibility can be resolved using the SOAP implementation methodologies of Web services through an Internet Network. This resolves the major issue in a simple fashion and made the application-to-applications communication simpler. It acts as an Interface of the different applications. It not only solves the single-layered software problem but also a multi-layered architecture problem.
####Micro-Services
In short, the REST is the architectural style of the Micro-services. But It can also be Implemented even in many ways. Coming to the REST it shortened from the Representational State Transfer where it means that whatever the resource/objects present would be accessed with the URLs'
and the result would be transferred in JSON format. The REST couldn't be complete without the HTTP methods which are based on CRUD operations.
REST is a state transfer strategy method and stateless which means that the state would not be stored.

Example: You can Implement the HTTP methods on the object and the state of the resource is always checked, and the result is returned.
Suppose that I use the HTTP Delete method and delete an Image, I could never know that it is deleted unless the GET method is imposed on the same resource and result would be found to be not found and hence the resource is deleted. Hence it can be seen as the verification method for the deleted resources.

It is also to be noted that making use of URI's/URL's doesn't mean that you are using the microservices.URI's can also be used to access the other resources on the WEB.

***REST-API***
API is the way of implementing the web service access methodologies, where the services are taken and given. API acts as the gateway to Interact with any of the applications to the outside world, who wants to communicate with them.
Example: Facebook offers the "facebook share API" which can be used to share the specified sites on your facebook wall.
![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/05lkij75aequmahdlj8g.jpeg)
In simple API is the way of modern communication between the two applications, and the results are formatted in JSON.
The REST API is to make the resources available on the web through the REST architecture. Each of the resources in REST would have specific culture and feature viz UI, log in. Formally to be the give-and-take culture. And the API's can also be made a call through an app over the Inter-Network.
To make it simple, the collection of services gives an application, 
where data flows within the services to make it a complete architecture.
At last, API is not the same as of REST.

Points to Check:

* Differences between Service Provider and Service Requestor
* Differences between Monolithic and SOA
* Differences between SOAP and API
* Differences between the REST and API
* Differences between the Microservices and API
* Differences between the SOAP and SOA 

Image source: From Book "***Service-Oriented Architecture: A field guide to XML and Web services***".