Webservices Demystified

According to W3C Web service is

A web service is a software system designed to support interoperable machine-to-machine interaction over a network. It has an interface described in a machine-processable format (specifically WSDL). Other systems interact with the web service in a manner prescribed by its description using SOAP-messages, typically conveyed using HTTP with an XML serialization in conjunction with other web-related standards.

This definition may have made some sense in the SOAP era, but we are in REST era, so let’s define different properties of web services.

  1. A web service is a software system designed to support interoperable machine-to-machine interaction over a network. What does this mean? In simple term web services written in any language be it java node or python flask should have a way to communicate with one another
  2. Web Service should have a service definition which defines different URIs and request and response structure. We can use WSDL or Swagger(We used to use this in Urbanclap ) for the same
  3. We can use any transport protocol using HTTP or RPC within services
  4. We can use any data exchange format like JSON or XML.
Web Services


Lets us first discuss what everyone hates but Goldman Sachs loves .

SOAP

Soap stands for simple object access protocol. For a wide variety of time, SOAP is used in service-oriented architecture. It became the preferred protocol to achieve interoperability between applications.

Remember that SOAP is a protocol. SOAP is designed with a specification. It includes a WSDL file which has the required information about the web service does in addition to the location of the resources on the web service ie their URI .

SOAP API makes use of XML with a predefined structure for data exchange. A typical SOAP XML structure looks like the following

No alt text provided for this image


Typical SOAP Structure

Different parts of SOAP structure

  1. SOAP Envelope: Identifies the XML document as a SOAP message.
  2. SOAP Header: Contains header information.
  3. SOAP Body: Contains call and response information.

REST

Rest stands for Representation State Transfer . REST is an Architectural style in which a web service can only be treated as a RESTful service if it follows the constraints

  1. Client-Server : It is based on the client-server architecture
  2. Statelessness: State of the request is not saved at the server. We require all the information from the request to process it successfully. If two clients send the same request, they get a similar response.
  3. REST services permit different data exchange format such as Plain text, HTML, XML, JSON, etc. But the most preferred format for exchanging data is JSON.
  4. REST uses URI to locate a particular resource
  5. Layered System: A client cannot ordinarily tell whether it is connected directly to the end server, or to an intermediary along the way. If a proxy or load balancer is placed between the client and server, it won’t affect their communications, and there won’t be a need to update the client or server code. Intermediary servers can improve system scalability by enabling load balancing and by providing shared caches. Also, security can be added as a layer on top of the web services, and then clearly separate business logic from security logic. Adding security as a separate layer enforces security policies. Finally, it also means that a server can call multiple other servers to generate a response to the client. (Src: Wikipedia )
  6. Caches: RESTful clients and intermediaries can cache responses.

Web Service APIs which adhere to the REST architectural constraints are called RESTful APIs. Typical REST Apis make use of HTTP protocol and have the following properties :

1. URI (Uniform Resource Locator): URL on which resource at the web service can be accessed. E.g. GET /users/

2. HTTP Methods: Different Types of HTTP methods are as follows:

No alt text provided for this image

3 . Request and response data format which can anything ranging from JSON, XML to HTML. We prefer to use JSON as our data exchange format.

In Summary :

No alt text provided for this image





HEMANT KUMAR

SDE@BECIL a mini ratna PSU | LFX '24 CNCF - Antrea | IIIT A

4 年

Well written Tannishk Sharma

回复

要查看或添加评论,请登录

Tannishk Sharma的更多文章

  • Design Twitter Search

    Design Twitter Search

    Requirements Let us assume that Twitter has 1.5 billion total users, with 800 million daily active users.

    3 条评论
  • Designing PasteBin

    Designing PasteBin

    Lets design pastebin Pastebin is a simple service which allows its users to share text or images over the internet by…

    3 条评论

社区洞察

其他会员也浏览了