A web service is a software system that allows two different applications to communicate and exchange data over the Internet using standard web protocols. In simple terms, it is a service that one computer offers to another over the web, so that a program running on one platform can use the functionality of a program running on another platform. For example, when a travel website shows flight prices, it is actually requesting data from the airline's web service. This allows different organisations to share functionality without sharing their internal code.
Web services are platform-independent and language-independent. A web service built in Java can be used by a client written in Python, PHP, or any other language, because all communication happens through standard formats such as XML and JSON and standard protocols such as HTTP. This makes web services the backbone of modern distributed applications, cloud computing, and enterprise systems. They are the practical implementation of the service-oriented architecture (SOA).
In this chapter we will study the definition and components of web services, the two major styles of web services called SOAP and REST, the technologies such as XML, JSON, WSDL, and HTTP on which they depend, and how web services are created and consumed. We will also look at real-world examples and the advantages and disadvantages of web services. This chapter connects the concepts of XML, networking, and databases into a complete picture of modern web development.
2. Need and Advantages of Web Services
Organisations need to share data and functionality with partners, customers, and other systems. Web services solve this problem by exposing selected functions over the network. The main advantages of web services are listed below.
Interoperability: Applications built in different languages and running on different platforms can work together.
Reusability: The same web service can be used by many clients, avoiding repeated development.
Loose coupling: The client and server are independent; a change in the server does not break the client as long as the interface remains the same.
Standard protocols: Web services use open standards such as HTTP, XML, and JSON, so they can be accessed from anywhere.
Scalability: A web service can be used by a few clients or millions of clients without changing its design.
Cost effectiveness: Organisations need not build the same functionality themselves; they can subscribe to an existing service.
Because of these benefits, web services are used in banking, e-commerce, travel booking, weather reporting, payment gateways, and almost every modern software system.
3. Components of Web Services
A web service architecture consists of three main components.
Service Provider: The organisation or application that creates the web service and makes it available on the Internet. The provider hosts the service on a server.
Service Consumer (Client): The application that requests and uses the web service. It sends a request and receives a response.
Service Registry: A directory where service providers publish information about their services and where consumers can discover them. UDDI (Universal Description, Discovery, and Integration) is a registry standard.
The communication between these components happens through messages. The consumer sends a request message, and the provider sends back a response message. These messages are formatted in a standard language such as XML or JSON, so both sides understand them.
4. SOAP Web Services
SOAP stands for Simple Object Access Protocol. It is a protocol for exchanging structured information in the implementation of web services. SOAP messages are written in XML and are sent over transport protocols such as HTTP, SMTP, or TCP.
Features of SOAP
SOAP messages are XML documents containing an envelope, a header, a body, and optional fault elements.
The envelope defines the start and end of the message.
The body contains the actual request or response data.
SOAP is a strict, standards-based protocol defined by the W3C.
SOAP has built-in error handling through the fault element.
SOAP is platform and language independent but is more verbose and heavier than REST.
SOAP is often used in enterprise applications where security, reliability, and transaction support are critical, such as banking and financial services.
5. REST Web Services
REST stands for Representational State Transfer. It is an architectural style rather than a strict protocol. RESTful web services use HTTP methods directly, treating every resource as an addressable URL. The HTTP methods map to the basic operations of the web:
GET: Retrieves data from the server.
POST: Sends new data to be created.
PUT: Updates existing data.
DELETE: Removes data.
Features of REST
REST uses simple, lightweight messages in JSON or XML format.
Every resource has a unique URL, for example http://api.example.com/students/101.
REST is stateless, meaning each request is independent and contains all the information needed to process it.
REST is faster and lighter than SOAP because there is no heavy XML envelope.
REST is easy to implement and is the preferred style for public web APIs, mobile apps, and cloud services.
Because of its simplicity, REST has become the most popular style for building web services today.
6. Technologies Used in Web Services
Web services depend on a set of standard technologies.
XML: The markup language used to format the data exchanged in SOAP messages.
JSON (JavaScript Object Notation): A lightweight text format for data exchange, used widely in REST services. It is easy for both humans and machines to read.
HTTP/HTTPS: The protocol over which web service requests and responses travel.
WSDL (Web Services Description Language): An XML-based language that describes the operations a SOAP web service provides and how to call it. It is like a contract between the provider and the consumer.
UDDI (Universal Description, Discovery, and Integration): The registry where web services are published and discovered.
REST API: An interface through which REST web services are accessed using standard HTTP methods.
These technologies work together: WSDL describes the service, SOAP defines the message format, HTTP carries the messages, and XML or JSON formats the data.
7. Creating and Consuming Web Services
Creating a web service involves writing code that exposes certain functions over the network. A simple example of a web service could provide the weather of a city. The provider writes the function, publishes it on a server, and describes it using WSDL. The consumer then calls this service by sending an HTTP request to its URL and receives the response in XML or JSON.
In practice, a REST web service might return JSON like this for a weather request:
The client application parses this JSON and displays the weather. This example shows how web services make data available to any application, whether it is a website, a mobile app, or a desktop program. Popular real-world web services include Google Maps API, payment gateways, social media login APIs, and weather APIs.
8. SOAP vs REST
The following comparison helps in understanding when to use each style.
SOAP is a protocol; REST is an architectural style.
SOAP messages are always in XML; REST can use JSON or XML.
SOAP uses WSDL for description; REST uses simple URLs and HTTP methods.
SOAP is heavier and slower; REST is lighter and faster.
SOAP has built-in error handling and security standards; REST relies on HTTP for these.
SOAP suits enterprise and banking applications; REST suits public APIs, mobile, and cloud applications.
Both styles are valid; the choice depends on the requirements of the project.
Quick Revision Tables
Term
Full Form / Meaning
SOAP
Simple Object Access Protocol
REST
Representational State Transfer
WSDL
Web Services Description Language
UDDI
Universal Description, Discovery, and Integration
JSON
JavaScript Object Notation
HTTP
HyperText Transfer Protocol
API
Application Programming Interface
HTTP Method
Operation
GET
Retrieve data
POST
Create new data
PUT
Update existing data
DELETE
Remove data
Mind Map
graph TD
A["Web Services"] --> B["Components"]
A --> C["SOAP"]
A --> D["REST"]
A --> E["Technologies"]
A --> F["Advantages"]
B --> B1["Provider, Consumer, Registry"]
C --> C1["XML messages, Envelope, Fault"]
D --> D1["HTTP methods, JSON, URLs"]
E --> E1["XML, JSON, HTTP, WSDL, UDDI"]
F --> F1["Interoperability, Reusability"]
F --> F2["Loose coupling, Scalability"]
Important Diagrams (SVG)
Diagram 1: Web Service Communication Model
Diagram 2: SOAP Message Structure
Common Mistakes
Confusing SOAP with REST. SOAP is a strict protocol using XML envelopes, while REST is a lightweight architectural style using HTTP methods.
Thinking that JSON can be used in SOAP messages. SOAP messages must always be in XML format.
Believing that web services and websites are the same. A website displays pages for humans, while a web service provides data for applications.
Mixing up WSDL and UDDI. WSDL describes the service, while UDDI is the registry where services are published and discovered.
Forgetting that REST is stateless, meaning each request is independent and contains all needed information.
Using the wrong HTTP method, such as using GET for creating data instead of POST.
Assuming that a web service can only be consumed by one kind of platform. Web services are platform and language independent.
Exam Tips
Learn the full forms of SOAP, REST, WSDL, UDDI, JSON, and API, as these are frequently asked in one-mark questions.
Memorise the HTTP method mapping: GET retrieves, POST creates, PUT updates, DELETE removes.
Be able to list at least three advantages of web services with a short explanation for each.
Compare SOAP and REST in a table for descriptive answers, focusing on protocol vs style and XML vs JSON.
Describe the components provider, consumer, and registry with a neat diagram in essay answers.
Remember a real-world example such as Google Maps API or a payment gateway to make answers impressive.
Conclusion
Web services are the modern way for applications to communicate and share functionality over the Internet. In this chapter we learned about the three components of web services, the service provider, the consumer, and the registry, and studied the two major styles: SOAP, a strict XML-based protocol ideal for enterprise systems, and REST, a lightweight HTTP-based architectural style ideal for public APIs and mobile applications. We also explored the supporting technologies including XML, JSON, HTTP, WSDL, and UDDI. Web services provide interoperability, reusability, and scalability, making them essential for e-commerce, banking, cloud services, and countless other applications.