WEB SERVICES & SOAP VS. REST

Web Services

✵ It is basically a XML-based information exchange system that is designed with the intention of performing specific tasks over the Internet or private (intranet) networks.

✵ Use of open protocols and standards such as TCP/IP, HTTP, XML, WSDL, Java and HTML has made this interoperable.

✵ Web services in cloud computing can be discovered over the network using simple find mechanism and can also be invoked accordingly.

✵ Once invoked, web services must be able to provide clients with functionalities.

How Web Services Work

✵ Web services use;

➢ XML — To tag data

➢ WSDL — To describe service availability

➢ SOAP — To transfer messages

✵ XML that stands for Extensible markup language (General-purpose data document format), is known as the main component of a web service design.

✵ XML caters a common platform for applications implemented using various programming languages to communicate with each other.

✵ The client is capable of invoking multiple web service calls to a server in which the actual we service is hosted, via requests. These requests are made via Remote Procedure Calls.

Remote Procedure Calls

☛ Define the functions that will be available remotely.

☛ These functions form the interface of the server.

Ex: int getCustomerID(int customer name)

🔹 RPC proxy/stub: code that goes on the client side, so the client can use the function.

🔹 RPC skeleton (outdated): the empty function that goes on the server side ready for the developer to complete.

Benefits of Web Services

🟢 Interoperability

🟢 A Standardized Protocol which can be understood by anyone

🟢 Exposing existing Functionality on the network

🟢 Ease of use

Web Service Characteristics

🔵 Synchronous or Asynchronous functionality

🔵 Supports Remote Procedure Calls(RPCs)

🔵 Loosely Coupled

🔵 Supports Document Exchange

Web Service Architecture

✵ The web service architecture has 3 major components.

1. Service Provider

2. Service Requestor

3. Service Registry

Types of Web Services

  1. SOAP web services.
  2. RESTful web services.

SOAP Web Services (Simple Object Access Protocol)

✽ IT is a strictly defined XML based message format.

✽ Specifically focused on passes RPC calls across the internet.
◦ defines how to marshall a function name and parameters into an XML message.
◦ Sending the message to the server then ‘does’ the RPC.

✽ The data which is transmitted from the web service to the application is known as a SOAP message. The SOAP is basically an XML document.

✽ The client application that is used to call the web service can be written in any programming language as the document is written in XML. There SOAP is language independent.

Advantages of SOAP

🟥 Defines its own WS security

🟥 Light-weighted protocol

🟥 Simple, extensible and platform independent

🟥 Let you get around firewalls.

SOAP Message Structure

A simple soap message contains following elements.

♦️ The Envelope element — It is the root element that encapsulates all the mandatory details of the SOAP message. It specifies the start and the end of a SOAP message.

♦️ The header element — If there is a header element inside envelope element, Only one header element should be there. Routing data and authentication information are included in header element and it comes as the first child of the Envelope.

♦️ The body element — Actual message is residing inside body. The body element consists of the web method definitions along with any parameter information if required.

♦️ The Fault element (Optional)

Disadvantages of SOAP

🟨 Slow

🟨 WSDL Dependent

🟨 Supports only XML

🟨 Tightly coupled

REST Architecture

✽ It expands the traditional GET and POST types

GET: read-only and safe.
POST: multiple requests can cause different results.
PUT: — multiple requests will result in the same outcome.
DELETE: — multiple requests will result in the same outcome.

RESTful Web Services

✽ Restful web services are scalable, maintainable, light-weighted and they define a Uniform Resource Identifier (URI), set of HTTP methods and provide resource representation such as JSON .

Key Elements of Restful Implementation

  1. Request Verbs — Indicate what to be done with the resource
  2. Request Headers — May define response types which are required or the details regarding authorization.
  3. Request Body — Information about the resource that should be added to the server.
  4. Response Body — Main body of the response
  5. Response Status codes — The general codes that comes back with web server responses.

Advantages of RESTful

🟥 Flexible

🟥 Supports multiple languages and environments

🟥 Simplify application design

RESTful Principles and Constraints

  1. RESTFul Client-Server — The client and server application need to be able to evolve independently.
  2. Stateless — Client must make sure that all the required information is provided correctly to the server. The server should not maintain any information between requests from the client.
  3. Cache — Can be implemented either on the server or the client side. Caching should be applied to resources when possible, and these resources MUST declare themselves cacheable.
  4. Layered System — The middleware layer where all the business logic is set up. A client is incapable of telling specifically whether it is connected directly to the end server or an intermediary along the way.
  5. Interface/Uniform Contract — The underlying method of how RESTful web services are working. RESTful usually works on the HTTP web layer.
  6. Code-on-Demand — This is one of the optional constraints where you are allowed to return executable code to support a part of your application.

Key Differences between SOAP and REST

References

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store