Introduction to Web Services: REST, SOAP and a Worked API Call
Build a clear model of web services, trace a REST request for a library system, calculate cold and reused-connection latency, and compare REST with SOAP.
KnowledgeGate Team
Exam prep & CS education

A website, an API, and a web service all use familiar web technologies, but they are not interchangeable terms. That confusion makes otherwise simple objective questions feel vague. Machine-to-machine communication, REST requests and SOAP service exchanges use distinct structures and concepts. Identify the consumer, endpoint, request, representation and response, and avoid the usual category errors.
Web services: the machine-to-machine idea
A web service is a documented software interface through which one application requests data or an operation from another over a network. Its consumer is software. A website is mainly built for a person and usually returns HTML for a browser to render.
An API is any defined software interface. A web service is a network-accessible API using web-oriented standards. Every web service is an API, but an in-process library API is not a web service.
Web services operate at the application layer. Application Layer Protocols: DNS, HTTP, and Email, with a DNS Walk-through explains that boundary. The service exchange is distinct from its DNS resolution.
Web service architecture: consumer, endpoint, contract and message
LibraryApp is the service consumer. It asks the provider, BookService, for book ID 42 through endpoint URI https://api.example.edu/books/42.
The remaining vocabulary fits around them:
The operation or resource is the action or thing exposed, here the book with ID
42.The request states what the consumer wants, and the response states the outcome.
A representation serialises resource data, such as a JSON or XML document.
A schema or contract defines valid operations, fields and data types.
The transport carries messages, while service logic validates the request, reads
BooksDBand prepares the result.
Keep the layers separate. HTTPS protects the exchange, HTTP supplies request-response semantics, and JSON or XML serialises data. The contract lists valid fields and operations.
Use HTTP Protocol Explained for message syntax, caching and multi-object RTT patterns. The LibraryApp service call below instead isolates REST and SOAP semantics, plus the cost of a cold versus reused connection.

REST web services: resources, methods and representations
REST is an architectural style, not a wire protocol. A URI names a resource, an HTTP method expresses intent, and a status code reports the result. Plausible mappings are GET /books/42 to retrieve, POST /books to create, PUT /books/42 to replace, and DELETE /books/42 to remove. A real API need not expose all four.
The method properties matter:
GETis safe because its intended semantics do not request a state change. It is also idempotent because repeating it has the same intended effect.PUTandDELETEare idempotent but not safe. Repeating the same request should leave the resource in the same final state, even if individual response codes differ.POSTis generally neither safe nor idempotent. Repetition may create more than one result.
Statelessness means each request carries the context needed to understand that request. It does not mean that the provider cannot have a database, user records or other persistent data.
Book 42 is the resource. {"id":42,"title":"Computer Networks","available":true} is one JSON representation of it. REST may use JSON or XML, so the claim that REST equals JSON is false.
Web service worked example: trace GET /books/42 and calculate latency
The client sends:
GET /books/42 HTTP/1.1
Host: api.example.edu
Accept: application/jsonThe service replies:
HTTP/1.1 200 OK
Content-Type: application/json
{"id":42,"title":"Computer Networks","available":true}That short object is an excerpt. For the timing calculation, assume the complete representation is 24 KiB. Also assume a DNS lookup of 20 ms, a network round-trip time of 40 ms, server processing of 8 ms, and a transfer rate of 12,000,000 bit/s.
For a cold call:
DNS lookup =
20 ms.TCP handshake =
1 RTT = 40 ms.TLS 1.3 handshake =
1 RTT = 40 ms.HTTP request to first response byte network time =
1 RTT = 40 ms.Server processing =
8 ms.Payload size =
24 x 1024 x 8 = 196,608 bits.Transfer time =
196,608 / 12,000,000 = 0.016384 s = 16.384 ms.Total latency =
20 + 40 + 40 + 40 + 8 + 16.384 = 164.384 ms.
Now use an already-resolved host with an existing TCP and TLS connection. Only the request-response network time, processing and payload transfer remain:
40 + 8 + 16.384 = 64.384 ms
Connection reuse therefore saves:
164.384 - 64.384 = 100 ms
This model ignores headers, congestion, loss and retransmission. Those omissions are assumptions, not claims that real networks lack these costs.

SOAP web services: envelope, WSDL and faults
SOAP is a messaging protocol with an XML envelope. The book lookup could be an HTTP POST to /LibraryService. Its SOAP body would contain GetBook with Id=42. The response would contain book data or a SOAP Fault.
WSDL is a machine-readable service contract that describes operations, message types and endpoints. Textbooks often pair SOAP with UDDI, the classic registry or discovery component, but a modern service does not require a public UDDI registry.
The key category distinction is simple: SOAP is a protocol, while REST is an architectural style. SOAP can be transported over HTTP, but using HTTP POST does not make a SOAP service RESTful.
REST vs SOAP: the distinctions and traps that matter
Point | REST | SOAP |
|---|---|---|
Nature | Architectural style | Protocol |
Message format | Commonly JSON or XML | XML envelope |
Contract | Often OpenAPI or another API description | WSDL |
Error model | HTTP status plus application error body | SOAP Fault |
Typical fit | Lightweight resource-oriented services | Formal contracts and WS-* requirements |
Do not classify a service from one token. JSON is not REST by itself, and XML is not always SOAP. HTTP is an application-layer protocol that can carry either style, not a synonym for either one. A 200 OK response can also contain a poorly designed application-level error, so inspect the HTTP status and the application body.
ID 42 makes idempotence concrete. Repeated GET /books/42 calls should not request a state change. Repeated PUT /books/42 calls with the same complete representation should converge to the same resource state. Repeated POST /loans calls may create multiple loan records.
Web services exam patterns: identify, trace and compare
Questions can ask you to label provider and consumer, match SOAP with WSDL and an XML envelope, select a suitable HTTP method or status family, distinguish safe from idempotent, or trace the 164.384 ms latency model when the question states every assumption.
Use a three-step routine:
Classify each term as architecture, protocol, format or contract.
Trace the request from consumer to endpoint and the response back.
Test the exact wording around safe, idempotent, stateless and stateful data.
KnowledgeGate has over 25 questions available in its practice bank on Introduction to Web Services. After learning the model, use Application Layer MCQs: 12 Solved DNS, HTTP, Email to practise nearby application-layer distinctions. For wider syllabus planning, see the GATE CS Exam Preparation Courses & Test Series category.
Web services: the short version and next step
Keep this five-line mental model:
The consumer calls an endpoint.
The method expresses intent.
The message carries a representation.
The provider executes service logic.
The response returns status plus data or a fault.
REST is an architectural style. SOAP is a protocol. Redraw the LibraryApp -> BookService -> BooksDB path, then recompute 164.384 ms and 64.384 ms without looking above. For a structured route through Computer Networks and its Application Layer unit, continue with GATE Guidance by Sanchit Sir.
Keep learning
Introduction to Web Services MCQs: 12 Solved Questions on WWW, URLs and Web 2.0
Solve 12 Introduction to Web Services MCQs on search engines, URL parts, WWW components, browser flow, hypertext, wikis and Web 2.0, with clear explanations.
Express.js REST API Tutorial: Routing, Middleware, and Error Handling the Production Way
Build one small courses API and trace every request through parsing, routing, 404 handling, and a single error path.
PHP vs Node.js: Choose by Building the Same CRUD API
Build the same BookStock API in PHP and Node.js, then compare request scheduling, validation, concurrent updates and deployment constraints.
Internet Protocols and Web Services: DNS, HTTP, Email and FTP with Worked Examples
Trace a browser request through DNS, TCP and HTTP, then separate email from FTP.





