ЁЯТ╗
тМия╕П
ЁЯЦ▒я╕П
ЁЯЦея╕П
ЁЯТ╛
тЖР Back to Dashboard
Font Size:

1. Introduction

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.

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.

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 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:

Features of REST

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.

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:

{
  "city": "Delhi",
  "temperature": 32,
  "unit": "Celsius"
}

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.

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

Service Consumer Client Application Service Provider Server with Web Service Request (HTTP + XML/JSON) Response (HTTP + XML/JSON) Service Registry (UDDI) Publish and discover services Golden Rule: The consumer sends a request and the provider sends back a response.

Diagram 2: SOAP Message Structure

SOAP Envelope SOAP Header Optional metadata such as authentication and routing info SOAP Body Actual request or response data <getWeather>Delhi</getWeather> Fault Element Reports errors (optional) Golden Rule: A SOAP message is an XML document with an envelope, header, and body.

Common Mistakes

  1. Confusing SOAP with REST. SOAP is a strict protocol using XML envelopes, while REST is a lightweight architectural style using HTTP methods.
  2. Thinking that JSON can be used in SOAP messages. SOAP messages must always be in XML format.
  3. Believing that web services and websites are the same. A website displays pages for humans, while a web service provides data for applications.
  4. Mixing up WSDL and UDDI. WSDL describes the service, while UDDI is the registry where services are published and discovered.
  5. Forgetting that REST is stateless, meaning each request is independent and contains all needed information.
  6. Using the wrong HTTP method, such as using GET for creating data instead of POST.
  7. Assuming that a web service can only be consumed by one kind of platform. Web services are platform and language independent.

Exam Tips

  1. Learn the full forms of SOAP, REST, WSDL, UDDI, JSON, and API, as these are frequently asked in one-mark questions.
  2. Memorise the HTTP method mapping: GET retrieves, POST creates, PUT updates, DELETE removes.
  3. Be able to list at least three advantages of web services with a short explanation for each.
  4. Compare SOAP and REST in a table for descriptive answers, focusing on protocol vs style and XML vs JSON.
  5. Describe the components provider, consumer, and registry with a neat diagram in essay answers.
  6. 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.