Hansini Rupasinghe
6 min readMay 15, 2021


Web Services

✵ A web service can be known as a self contained, modular and dynamic medium that is mainly used to communicate between client and server applications or software over the web.

✵ 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

🟢 Communication cost is low

🟢 Interoperability

🟢 A Standardized Protocol which can be understood by anyone

🟢 Exposing existing Functionality on the network

🟢 Ease of use

Web Service Characteristics

🔵 XML-Based

🔵 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

Web service is created by the Service provider and makes it available on the internet for whoever wants to utilize it.

2. Service Requestor

The client application which is needed to be contacted by a web service through starting a network connection and sending an XML request.

3. Service Registry

It is a directory of services that is centralized logically with the purpose of giving opportunity for the developers to publish new services or find existing ones.

Types of Web Services

There are 2 main types of web services.

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

SOAP Web Services (Simple Object Access Protocol)

✽ SOAP (Simple Object Access Protocol) is a communication protocol which is used in web services in order to send the XML data between applications over normal HTTP.

✽ 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

✽ REST (Representational State Transfer) defines a set of constraints that define how a server is created/setup. (i.e. a RESTful Server)

✽ 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 built on REST architecture based on HTTP methods.

✽ 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. Resources — The first key element
  2. Request Verbs — Indicate what to be done with the resource
  3. Request Headers — May define response types which are required or the details regarding authorization.
  4. Request Body — Information about the resource that should be added to the server.
  5. Response Body — Main body of the response
  6. 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