“Web Service is a software system designed to support interoperable machine-to-machine interaction over a network” (W3 Definition).
“Web services are self contained, self describing, modular applications that can be published, located, and invoked across the web. Web services perform functions, which can be anything from simple requests to complicated business processes.” (IBM)
The quality of web services is depends on some key factors.
- Performance: Like response time, Latency, Execution time,
- Availability: Probability of given request access with the service,
- Reliability: Probability of given request is successfully invoked the service.
Types of Web services.
ex: SOAP (Simple Object Access Protocol)
ex: REST (Representational State Transfer)
Let’s discuss each of the web service in a detailed manner. But before going through SOAP and RESTful web services, let me recap your knowledge about OSI model which describes how our http messages are going through different layers.
OSI (Open System Interconnection) Model
This model consists with 7 layers it self used by computer systems to make a communication over computer network. Let’s discuss about the each layer.
- Application: Receive data from outside and send to the presentation layer.
- Presentation: Format data (encrypt, compress) in order to place them on network.
- Session: Make connection with the receiver’s place.
- Transport: Formatted message is brake down in to the small packets and label them in order to place them in network as regularly.
- Network: Add logical address to each small packet to ensure the location.
- Data-link: Add physical address to each packet. Other than that this also adds Cyclic Redundency Checks (CRC) to ensure error free delivery. As well, data link layer is responsible for monitor network and decide when to sent the packets.
- Physical: Each bit received from data-link layer made in to the appropriate format. For an instance, if it is a wired network, transmit each bit in to electric signal.
- Physical: Receiver’s physical layer receives signals in its format and transform them in to the 0 and 1. Then pass to data-link layer.
- Data-link: It gains each bit in to the frame. Also, verify before theses frames send to above layer by ensuring it is error free delivery through CRC. Other than that physical address of receiving computer is also verified. If it is verified properly, then remove the address and send to the network layer. Otherwise, drop the packet.
- Network: Check the logical address of receiving machine and verified it. If it is verified properly, then remove the logical address and send to transport layer. Otherwise, the packet is removed.
- Transport: Gather all the packets received and make a whole message. Then pass to the session layer.
- Session: Close the connection between sender and receiver after the message is received.
- Presentation: In here, undo all the formatting done by sender. If it is encrypted then decrypted.
- Application: Received data is passed to the suitable server to obtain corresponding services.
SOAP (Simple Object Access Protocol)
In the scope of SOAP, what it does is provide a way for a program running on one Operating System (OS) and allow to communicate with another program which is running on either same or different OS though transport protocols (like HTTP, TCP, SMTP etc.) and XML (eXtensible Markup Language).
In that case what SOAP does is,
1. Send and Receive transport protocol packets
2. Process XML messages.
However, in the most of cases SOAP uses HTTP as its transportation protocol. The industry leading companies like HP, Oracle, SAP and etc. implement SOAP services with their systems.
The components of SOAP message:
Think about when you are sending a mail through post office, you are writing on your envelop about receiver’s address and put a stamp also.
Likewise, in SOAP envelop also specifies who should deal with the message.
Inside the letter which you post, you write about your address, date, receiver’s address and so on. Then sender can identify about you by looking at the message header.
SOAP header has credential information to control the third party accesses for operations and to specify who should deal (SOAP Actor)with as well what they can do with it.
There are 3 types of SOAP actors. They are,
- None: The receiver does not need to process the data.
- Next: The received node can process the data.
- Ultimate receiver: Final recipient of the message.
As well SOAP header has an attribute called mustUnderstand. It has values of 0 and 1. It specifies is it must to process the received message by SOAP actor.
It shows the major part of the message which need to be processed by either client or web service. You must have a body element in SOPA message.
SOAP Fault codes
These codes provide the types of errors in SOAP messages.
SOAP services can work in synchronized and asynchronized manner. Synchronized is in the sense, the client sends request to the web server and wait until receive a response by halting other operations. In Asynchronous manner, you can send multiple requests to the server and no need to wait until you receive the response, you may carry out the other tasks.
RESTful (Representational State Transfer)
RESTful web services are belongs to Resource-oriented architectures. RESTful is built on top of the RESTful architecture. In this architecture, all the services and components are treated as the resources which are represented in text file, web page, videos, images, XML,JSON and so on. But the most used format is XML. Each resource is identified by Uniform Resource Identifier (URIs). Basically RESTful web services use to build the web application APIs. The REST web service is also accessible by standard protocol of HTTP. Therefore, the communication between web client and server is provided through HTTP request and response.
Following shows about the common HTTP methods which are used by RESTful web service.
- GET — Make read only access to resource,
- POST — Create a new resource,
- DELETE — Delete existing resource,
- PUT — Alter existing resource or create new resource.
Let’s discuss about the components of HTTP request and response.
The web-based software applications can be written in different languages and on different platforms. In order to communicate with each other, REST web services can be used.
Key features of RESTful: Light-weighted, scalable and maintainable. And furthermore, RESTful send and receive requests and responses in synchronized manner.
Let’s make a comparison between SOAP and REST.
In order to make REST web services in synchronized manner we can use Message Brokers.
The message broker is a framework which helps to provide middleware as a communication media between the sender and receiver known as Message Broker. The message brokers can facilitate the communication between interdependent web applications even if they written in different languages. As well, it is used to validate, store, route and deliver the message for appropriate destination. The message broker has message queue to with the exact order of messages in order to provide them for corresponding recipients.
Message broker makes RESTful web services asynchronously and make the available services more efficient.
There are 2 types of message broker models are available.
- Point-to-Point Messaging
- A message in the queue is sent to only one receiver at once. That means only one receiver (Consumer) can consume the message sent by sender (Producer).
- More than one sender can sends the message to the queue via same or different connections.
- More than one receiver can receives messages from the queue. But, one message should be received by only one receiver.
- Senders and receivers can add or remove dynamically at run time.
- Employee of the organization should receive his/her own payroll transactional details, not for others.
2. Publish/Subscribe Messaging
- In that case, more than one receiver receives messages from sender since they have subscribe the service.
- As well, the sender does not know who are asking for the services and to who he is producing the services.
Let’s say one you tube channel can be subscribed by so many people who have passion on that particular channel. So, when the channel owner uploads a new video, each and every subscriber gets a notification.
Popular Message Broker platforms are:
- Apache Kafka
- AWS Amazon MQ
So, I hope you got a clear idea about the web services and related areas in detailed manner regarding OSI model, SOAP, RESTful API and Message Broker.