SOAP (Simple Object Access Protocol) is a lightweight internet messaging protocol that facilitates message exchange between applications and backend systems. These messages are packaged in a structured XML format and enables communication independent of an application's, server's, or networking component's programming language, often via a SOAP API.
Because SOAP relies on transport protocols such as HTTP or SMTP, it's considered a Layer 7 (application layer) protocol within the Open Systems Interconnection (OSI) Model. The SOAP specification is known for being relatively rigid — laying out a clear blueprint for implementation and API design — yet offers good extensibility in exchange. Thanks to this and other SOAP characteristics such as built-in error handling, compatibility within distributed environments, strong security, and platform agnosticism, the protocol has gained popularity in enterprise environments.
The Internet Engineering Task Force (IETF) first standardized SOAP in 1999 following Microsoft's submission of the protocol. Later that same year, SOAP 1.0 launched with a host of standard "modules" allowing for quick expansion of its basic functionality. While SOAP's popularity has somewhat waned with the introduction of new technologies (such as REST), the protocol remains popular within business and legacy infrastructure setups.
How does the SOAP protocol work?
The SOAP protocol and XML
SOAP messages are formatted in XML as opposed to JSON or other formats. XML is great — it's been used for ages, it's extensible as mentioned, and works well with a wide variety of backend systems. You only need to use the parts you need, cutting bloat, and it provides good data integrity. XML also excels at enabling businesses to seamlessly process transactions amongst themselves without sharing sensitive information.
However, the XML format does present its challenges. While XML is widely used and known, the format can introduce some integration complexities depending on which programming languages your other networking components use. Java, Kotlin, and .NET specifically provide good automation and translation support for crafting SOAP requests and response types without excess code. However, newer languages may drop support for many of SOAP's Web Services Description Language (WSDL) shortcuts.
SOAP protocol components
A SOAP message is composed of the following standardized pieces:
Envelope – Defines the structure of each message, and contains a mandatory
<body>element and<header>element. You're effectively packaging (or wrapping) a specialized HTTP request in a SOAP envelope to leverage the protocol.Header – Optionally provides informative context about the applications (such as encryption details), which may be required when working with certain WSDL files. This must be the envelope's first child element when included.
Body – Contains the message contents themselves and information on any faults, such as errors
Fault – Optionally relays application health status while cataloging any errors during runtime
Encoding – Enforces data type expressions directly within the message while simplifying the processes of serialization and deserialization
A standard SOAP message is therefore pretty flexible, but may have some dependencies on modules required to to enable deeper extensibility. While other APIs such as RESTful ones are primarily data-driven (meaning they can directly add, delete, or modify data on the backend), SOAP APIs define operations or functions related to internal business units.
SOAP messages can also be larger than those served over other protocols. They contain a large quantity of contextual information about the application and clients, plus any logic for the backend to process. Unlike with REST, SOAP messages also aren't cacheable since they leverage the HTTP POST method. These attributes may contribute to slowdowns at scale as message volumes and payloads increase.
SOAP protocol standards
SOAP messages optionally use a combination of the following standards to provide robust functionality:
Web Services Security (WS-Security) – Enhances each message with privacy controls, authentication, and paired security tokens to ensure safety in transit. You can describe credentials within each message and help ensure integrity.
Web Services Addressing (WS-Addressing) – Helps provide interoperability between connected services by specifying endpoint references, message addressing properties, and associated parameters impacting who receives the message (plus the unique message ID)
Web Services ReliableMessaging (WS-ReliableMessaging) – Determines how errors are handled and helps ensure success sending and receipt of messages across the network
Web Services Description Language (WSDL) – Determines how SOAP-based services work and how within a configurable XML file. XML documents are always returned within each SOAP API response.
What are the benefits of the SOAP protocol?
The SOAP protocol has been a workhorse for over 25 years, and thus offers the following advantages to organizations:
SOAP is built for use with any application (including programming language), platform, or operating system. It also accommodates a number of transport protocols vs. being restricted to HTTP only.
SOAP is relatively lightweight due to its reliance on XML.
SOAP is secure, compliant, and offers built-in error correction to aid troubleshooting — and prevent issues downstream.
SOAP works well in distributed, multi-cloud environments where business units are logically separated.
SOAP makes ample use of automation, based on application programming language, to make development easier.
You’ve mastered one topic, but why stop there?
Our blog delivers the expert insights, industry analysis, and helpful tips you need to build resilient, high-performance services.
Does HAProxy support SOAP applications?
Yes! HAProxy and HAProxy One support SOAP applications and offer unmatched support for other common internet protocols — such as HTTP — that SOAP messages may use as their transport protocol. HAProxy and HAProxy One also work in mixed architectures where applications and APIs leverage a variety of messaging protocols.
To learn more about SOAP support in HAProxy, check out our HAProxyConf presentation, HAProxy as Egress Controller.