technolog | web-services
Skillfluencer 1 year ago
skillfluencer #technology

What is web service

Hello Everyone! I hope you are doing good. In this post we will cover the basics of web-services. We will understand the definition of web-service given by W3C (World Wide Web Consortium) with the help of an example to understand it in layman’s term. This is the first post in the web-services series so do check the next posts since we are going to cover everything about web-services and even talk about micro-services and different types of architecture and design patterns used by tech giants.

So Let’s begin with an example to understand what is web-service

Let's say for example, a person who is in Powai(Mumbai) is hungry and wants to have Burger and a Coke. Also, consider that there is no food ordering app in place like Zomato or Swiggy and he has to visit the restaurant which serves the Burger.

So, following are some of the key points that he must know at least to get his requirement fulfilled.

  1. Location
  2. Address
  3. Menu-Card details (so that he knows that restaurant serves the burger)
  4. Status (is it Open or closed)

Refer the below diagram, there are four restaurants available but out of that he only knows three restaurants. So, the fourth restaurant is highlighted in black and it doesn't exist for him.


web-service-analogy

Let us assume that he selected McDonalds restaurant after checking the above mentioned points. He visits the restaurant and stand in queue at the order desk. After checking the Menu-Card, he selects an item and asks(requests) Representative to get McVeggie Burger and a Coke.

Now, depending on the availability the Representative will either respond back with a positive or negative response.


The same conversation is depicted in the diagram below.

  1. Positive Response


webservice-positive-responsea

2. Negative Response

webservice-negative-responsea

Now, let's take this example one step ahead and consider that you are building a food ordering application(FO app). So, now that person will order food from your app instead of visiting the restaurant.

So, instead of interacting with the Restaurant representative, he will interact with the application that you have created. So now, your application will show him the list of restaurants in a given location, the menu-card, status and everything.

But to show all these details your application needs to interact with another application(for simplicity we will say it is another application), which stores these information in a repository. Consider this as a yellow pages or Just Dial or dictionary of all the restaurants.(Refer below diagram)


webservice-restaurant-API-integration

To do this, now your application needs to know following things about that another(ex: Justdiial.com) application:

  1. Location i.e Web
  2. Address i.e https://anotherapplication.com
  3. Status - whether that application is Active or Inactive.
  4. Menu-Card - This will list the services/ endpoints supported by the application (Refer below diagrams)
  • GET /restaurants?location=powai&status=open - To get all restaurant in Powai location with status Open
  • POST /restaurants - To create a new restaurant in the database
  • GET /restaurants/restaurant-id - To get a single restaurant
  • POST /orders - To create new order

If you compare the above points with the previous points(highlighted in bold) that we have mentioned above when we considered that person visited the restaurant, you will find that these points are analogous.

So, now when a user interacts with your application and tries to get all restaurant in Powai location with status Open, then our application in turn will call another application(restaurant repository) to get these details and it will use the above Location, address, Menu-card and status before calling it.

These two applications might be deployed/installed on different servers for example one is in Mumbai and other might be in US, but they still can interact with each other over the web(internet).

So if you want to define this in simple words then you can say that, "our application is calling another application over the web and connecting from one machine to another to get the job done".

This is actually called as web-service call. The calling app is the service requester and the application that is being called is the service provider.

webservice-restaurant-API-GET-endpoints webservice-restaurant-API-POST-endpoints

What is Web-service?

A web-service follow a standard which is called W3C(World Wide Web Consortium). Based on the definition of W3C a web-service is a software designed to support Interoperable machine to machine interaction over a network.

The key points here are:

  1. Interoperable - i.e Platform Independent
  2. Machine-to-Machine - i.e Application to Application
  3. Interaction - i.e Communication which is over network(Web)

To explain this, refer below diagram. There are three applications built in three different programming languages and might be deployed on different env. or platform. But the Web-service which they all are calling(sending requests to) will accept their requests and give response that is understandable by those application(based on the pre-decided API documentation in simple words the menu-card of the application).

And thus the web-service should be able to communicate with all the platforms and should be able to serve the requests to all of them.

webservice-definition

I hope until now you have followed and understood everything. In the next post we will cover different types of web-services like SOAP and REST, different types of request and response formats like xml, json ,html, etc. so do checkout our next post in the web-services series. Also, do share this post with your friends and colleagues and post comment to ask any questions or give any feedback. We are always open for suggestions.


Do visit again, till then good bye and happy learning.

0
226
Kafka for Beginners

Kafka for Beginners

1657353768.png
Skillfluencer
1 year ago
What is Split io?

What is Split io?

1657353768.png
Skillfluencer
1 year ago
React js Architecture

React js Architecture

1657353768.png
Skillfluencer
1 year ago
What is GraphQL?

What is GraphQL?

1657353768.png
Skillfluencer
1 year ago
Message Queuing service

Message Queuing service

1657353768.png
Skillfluencer
1 year ago