What are XML Web Services?

Estimated study time: 14 minutes.

An XML web service is a way for applications running on different platforms to talk to each other over the internet, using XML as the common language for requests and responses.

The Core Idea

Two systems don't need to share a programming language, operating system, or database — as long as both can send and understand XML over standard web protocols like HTTP, they can exchange data.

Typical Building Blocks

  • SOAP — a strict, XML-based messaging protocol for web services.
  • WSDL — an XML document that describes what a web service offers and how to call it.
  • REST (with XML) — a lighter approach where XML is exchanged over standard HTTP verbs.
  • UDDI — a (largely historical) directory for discovering available web services.

A Simple Request/Response Flow

Client  --request (XML)-->  Web Service
Client  <--response (XML)--  Web Service

Where They're Still Used

XML web services are common in banking, government, healthcare, and other enterprise systems where formal contracts, strict validation, and interoperability with older systems matter more than raw simplicity.

💡 Tip: Even though REST with JSON dominates modern APIs, XML web services (especially SOAP) are still very much alive in large enterprise and government systems — it's a valuable skill to have.

Inside a SOAP Request and Response

A SOAP message is an XML document with a fixed outer shape. The Envelope wraps everything, an optional Header carries extra information such as security tokens, and the Body holds the actual operation and its data. Here is a SOAP 1.1 request asking a stock service for a price:

POST /StockService HTTP/1.1
Host: api.example.com
Content-Type: text/xml; charset=utf-8
SOAPAction: "urn:GetPrice"

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Header/>
  <soap:Body>
    <GetPrice xmlns="urn:example:stock">
      <Symbol>INFY</Symbol>
    </GetPrice>
  </soap:Body>
</soap:Envelope>

A successful reply follows the same envelope pattern, with a response element inside the body. When something goes wrong, the body contains a Fault element instead:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <soap:Fault>
      <faultcode>soap:Client</faultcode>
      <faultstring>Unknown stock symbol</faultstring>
    </soap:Fault>
  </soap:Body>
</soap:Envelope>

A Client fault code means the request was wrong, while a Server fault code means the service failed while handling a valid request. SOAP 1.2 uses the media type application/soap+xml, a different envelope namespace and slightly different fault element names.

How a Client Uses a WSDL, Step by Step

The WSDL file acts as the contract between both sides. A WSDL 1.1 document is organised into sections that answer different questions:

SectionAnswers
typesWhat do the data structures look like? (usually XML Schema)
messageWhat goes in and out of each call?
portTypeWhich operations exist?
bindingWhich protocol and message style are used?
serviceAt which address does the service live?
  1. The client developer obtains the WSDL from the provider.
  2. A tool reads it and generates client classes, so code can call GetPrice("INFY") like a normal method. Java, .NET and many other platforms include such generators.
  3. At runtime the generated code builds the XML envelope, sends it over HTTP and parses the reply back into objects.
  4. If the provider changes the contract, the client regenerates its classes from the new WSDL.

Testers often load the same WSDL into a tool such as SoapUI or Postman to create sample requests for every operation automatically.

SOAP or REST: Choosing the Right Style

ConsiderationSOAPREST
ContractFormal WSDL and schemaOften an OpenAPI description, not mandatory
Message formatAlways XMLUsually JSON, XML possible
Standards for security and reliabilityWS-Security and related specificationsHTTPS plus tokens such as OAuth
Best fitEnterprise integrations with strict contractsWeb and mobile apps, public APIs

Safety and quality checklist

  • Always send XML web service traffic over HTTPS.
  • Validate incoming messages against the schema before processing them.
  • Configure XML parsers to disable DTDs and external entities, which protects against XML External Entity (XXE) attacks.
  • Return clear faults to callers without exposing stack traces or internal details.

Ready to go beyond the basics?

Get hands-on training, live mentorship, and placement support with the Data Analytics Course at Uncodemy.

Explore XML Course →