Skip to content
SEE Exam Prep

Question 8 of 11 · PYQ 2025 · 6 marks

Open in ChatGPT

Describe how SOAP facilitates communication in web services with an example.


Introduction

SOAP is a protocol for exchanging structured messages between services over any transport. Where REST uses HTTP's own semantics, SOAP wraps everything in one XML envelope and posts it to one endpoint.

The message

A SOAP message is an XML document with:

  1. Envelope: the root, marking the document as a SOAP message.
  2. Header (optional): metadata for intermediaries: security tokens, transaction ids, routing.
  3. Body: the actual call or the response.
  4. Fault (inside the body on error): a structured error with a code and a reason.

How it facilitates communication

  1. The service contract is published as WSDL: operations, messages, types and the binding to a transport.
  2. The client generates a proxy from the WSDL, so a remote call looks like a local method.
  3. The proxy serialises the arguments into a SOAP body and posts the envelope to the endpoint.
  4. Intermediaries can inspect and act on the header: authenticate, log, route: without touching the body.
  5. The server processes the body, returns an envelope with the result or a Fault.

Example

A flight-booking service exposes BookFlight(flightId, passenger).

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Header>
    <auth:Token>abc123</auth:Token>
  </soap:Header>
  <soap:Body>
    <BookFlight>
      <flightId>AI-202</flightId>
      <passenger>Ravi</passenger>
    </BookFlight>
  </soap:Body>
</soap:Envelope>

The reply carries <BookFlightResponse><bookingRef>... or a <soap:Fault> with faultcode and faultstring.

Why the envelope helps

  • Transport independence: the same message can go over HTTP, SMTP or a message queue.
  • Standards on top: WS-Security signs and encrypts parts of the message; WS-AtomicTransaction coordinates commits; WS-ReliableMessaging guarantees delivery: all inside the header.
  • Strong typing: XML Schema validates the body, and WSDL makes the contract machine-checkable.

Limits

  • Verbose: a small call becomes kilobytes of XML.
  • HTTP caching is lost, because every operation is a POST to one URL.
  • Tooling is heavy, and the WS-* stack is hard to implement correctly.

Conclusion

SOAP trades verbosity and complexity for a formal contract and message-level standards. That is why banks and enterprise integrations still use it, and why public APIs moved to REST.