Actions

Simple Object Access Protocol (SOAP)

What is Simple Object Access Protocol (SOAP)?

SOAP (Simple Object Access Protocol)is a protocol specification for exchanging structured information in the implementation of web services in computer networks. It relies on XML as its message format and uses other application layer protocols, most notably HTTP and SMTP, as the transport protocols. SOAP can form the foundation layer of a web services protocol stack, providing a basic messaging framework for web services.


Simple Object Access Protocol (SOAP)
source: Microsoft


History of SOAP

Early Development and Version 1.0 Late 1990s: The origins of SOAP date back to the late 1990s. It started as an initiative by Microsoft, IBM, and other companies to standardize the way in which computers could use the internet to communicate with each other. It was initially designed as an object-access protocol and was developed as a successor to earlier technologies such as the Distributed Component Object Model (DCOM) and Common Object Request Broker Architecture (CORBA).

1998: Dave Winer, Don Box, Bob Atkinson, and Mohsen Al-Ghosein, who were working at Microsoft, along with various other contributors, played a key role in the initial development of SOAP. Their work was based on the XML-RPC protocol, which was itself built upon a foundation laid by earlier remote procedure call (RPC) protocols.

Version 1.1 and W3C Involvement May 2000: SOAP 1.1 was submitted to the World Wide Web Consortium (W3C) by Microsoft, IBM, and Ariba. W3C is an international community that develops open standards to ensure the long-term growth of the Web. SOAP 1.1 was built on XML and HTTP, which allowed for a simple way to invoke methods and access servers, services, and objects across the internet.

2000-2003: During this period, SOAP became increasingly popular as a way of communicating between applications without requiring any additional technologies or components. Various organizations started to see the value of using SOAP as a way to expose web services, and the protocol began to be widely adopted as a standard for web services communication.

Version 1.2 and Standardization June 24, 2003: SOAP 1.2 became a W3C recommendation. Unlike SOAP 1.1, which was focused on the remote procedure call (RPC) pattern, SOAP 1.2 provided the flexibility to apply it to a variety of messaging patterns. With this version, the W3C introduced the concept of a “message construct” that did not rely on RPC and could be used with various transport protocols, not just HTTP. This helped broaden the appeal and application of SOAP.

2007: The Web Services Reliable Messaging (WS-ReliableMessaging) and Web Services Security (WS-Security) specifications were developed. These extensions built upon SOAP to add new features and capabilities, particularly in terms of security, reliability, and transactions. These specifications helped to establish SOAP as a robust and secure protocol for enterprise-level web services.

Further Adoption and Use Cases Mid-2000s to Present: SOAP has been a fundamental protocol for enabling web services in enterprise environments due to its robustness, security, and standardization. Industries like finance, healthcare, and telecommunications, which require secure and ACID-compliant transactions, have been significant adopters of SOAP-based web services.

SOAP vs. REST: As the technology world evolved, especially with the advent of mobile and cloud computing, there was a growing trend towards using simpler, more lightweight protocols. This has led to the widespread adoption of Representational State Transfer (REST) as an alternative to SOAP for certain types of services, particularly those that are public-facing and do not require extensive security features. Nonetheless, SOAP remains heavily used for service interfaces that require complex operations and strong security, such as in enterprise-level applications and services.

Legacy and Ongoing Use Today: SOAP is still widely used in various industries, especially in scenarios where there is a need for high security, reliability, and ACID-compliant transactions. It is a key component in various WS-* standards for web services and continues to be used in conjunction with a multitude of other protocols and technologies.


Characteristics of Simple Object Access Protocol (SOAP)

  • XML-Based Message Protocol: SOAP uses XML (eXtensible Markup Language) as its message format, which is widely used, text-based, and readable by humans and machines alike. This makes it both flexible and versatile, allowing for messages to be easily generated and interpreted by various systems.
  • Platform and Language Independent: SOAP messages are exchanged between nodes regardless of the operating system, programming language, or any other system-specific detail on which they are implemented. This makes SOAP an excellent choice for communications between different applications across diverse environments.
  • Support for Various Transport Protocols: SOAP can be used with a variety of transport protocols, including HTTP, SMTP, TCP, and more. It is commonly used over HTTP/HTTPS, making it easy to use through firewalls and proxies, which makes it web-friendly.
  • Request-Response Mechanism: SOAP supports synchronous and asynchronous operations. In a synchronous operation, the requester waits for the response message. In an asynchronous operation, the response message is sent at a later time.
  • Built-in Error Handling: If a SOAP receiver is unable to process a message for any reason, it constructs a SOAP Fault element that provides information about the error. This standard way of dealing with errors simplifies the task of identifying and handling errors in communication.
  • Security Features: SOAP, when used in combination with other WS standards (e.g., WS-Security), provides a comprehensive security model, supporting various authentication and authorization techniques, as well as message integrity and confidentiality.
  • Support for ACID-Compliant Transactions: SOAP can be used to ensure that a series of operations are carried out as a single, atomic transaction, in line with the ACID (Atomicity, Consistency, Isolation, Durability) properties.
  • Extensible: SOAP is designed to be extensible, meaning that it can be augmented with additional features and functions as needed. This is often achieved through the use of SOAP headers, which can carry additional, optional information pertinent to the request or response.
  • Stateless: Each SOAP message is an independent transaction and does not rely on any state information that is retained from previous messages. This statelessness is similar to the statelessness of HTTP, which is often used as the transport protocol for SOAP messages.
  • Standardized: SOAP is a W3C standard, which means it adheres to rigorously defined specifications. This standardization allows for interoperability between different software applications, as it provides a known, predictable framework for sending and receiving messages.
  • Support for Remote Procedure Calls (RPCs): SOAP is often used to implement web services as RPCs. In this model, a request message corresponding to a particular method or function call is sent to a remote service, and the response message contains the return value or output of that call.
  • Strong Typing: SOAP uses XML Schema (a W3C specification) to define the data types of the information in its messages. This enables detailed and precise specifications of the data structures that a SOAP message can contain, which can facilitate the validation of that data.
  • Verbose and Heavy: Due to its extensive use of XML and the comprehensive information it carries (including various headers and extensive type information), SOAP messages can become quite large and complex, which might lead to increased network traffic and processing time.
  • Strict Standards and Specifications: SOAP has a set of strict rules and specifications, which must be followed to ensure proper communication between different systems. This makes it robust but can also make it challenging to implement correctly.

These characteristics have made SOAP a prevalent protocol in enterprise environments where robustness, security, and reliability are critical, particularly in scenarios like financial transactions, healthcare data exchanges, and telecommunications. Nonetheless, the verbose and heavy nature of SOAP messages has also led to the rise of alternative, more lightweight protocols, particularly for public APIs and mobile or web applications.


Components and Structure of SOAP

The Simple Object Access Protocol (SOAP) is a protocol specification for exchanging structured information in the implementation of web services in computer networks. SOAP messages are XML-based and have a standard structure that consists of specific components. Below is a detailed description of these components and the overall structure of a SOAP message:

Envelope
The Envelope is the topmost element in a SOAP message. It defines the start and end of a message, making it clear what portions of the XML document are considered to be part of the SOAP message. It is a mandatory part of any SOAP message. The Envelope element encloses all other elements of the SOAP message.


Envelope


Header
The Header is an optional element used to contain application-specific information (like authentication, payment, etc.) or attributes of the message (like which web service action is being invoked). The Header element is used to add additional features and functionalities in the SOAP message. If specified, the Header is the first child element after the opening Envelope tag.


Header


SOAP headers can be marked as mandatory. If a SOAP processor receives a header that is marked as mandatory but doesn't understand how to process it, the message is rejected.

Body
The Body is a mandatory element and is used to contain the actual SOAP message intended for the ultimate endpoint of the message. It is the second child element after the opening Envelope tag. This is where the service request or response gets detailed.


Body.png


The Body element contains child elements, each representing a separate remote procedure call or a message. These elements are sometimes called SOAP body entries, and each one can encode the input or output parameters of a call.

Fault
The Fault element is an optional sub-element of the Body element. It is used to hold errors and status information for SOAP messages. If a Fault element is present, it must appear as a child of the Body element. This element is used to indicate error messages.


Fault element.png


faultcode: A code that categorizes the error. Standard fault codes are defined by the SOAP specification. faultstring: A human-readable description of the fault. faultactor: (Optional) Information about who caused the fault to happen within the message path. detail: (Optional) Specific application-level error information related to the Body element. It is used to provide more detailed error information.

Attachments (SOAP with Attachments)
Though not a part of the core SOAP specification, SOAP messages can be used in combination with attachments. SOAP with Attachments is a specific way to associate documents of any type with a SOAP message. The attachments are not part of the actual SOAP message but are part of the extended SOAP message package, which includes the SOAP envelope and its associated attachments. Examples of this usage include sending an image, audio, or complex business data in formats like PDF or Word.

Example of a Complete SOAP Message:
Here is an example of what a complete SOAP message might look like:


Example of Complete Soap Message.png


In this example:

The Envelope is identified by the soap: Envelope tag. The Header contains transaction details with the value "234". The Body contains a GetPrice request for stock with the symbol "GOOG". This structure of a SOAP message allows for highly extensible and structured communications that can be used across different platforms and programming languages, which has made SOAP a fundamental protocol for enabling web services, especially in enterprise-level applications.


Use Cases for Simple Object Access Protocol (SOAP)

  • Enterprise-Level Web Services: In large enterprises, especially in the financial and healthcare sectors, systems often require complex transactions, high security, and reliable messaging. SOAP's features, such as ACID-compliant transactions, built-in security protocols (when used with WS-Security), and extensive standards and specifications, make it an excellent fit for these environments.
  • Interoperable and Cross-Platform Communication: For systems that involve multiple different platforms, operating systems, and programming languages, SOAP's platform independence is a significant advantage. It ensures that disparate systems can communicate with each other using a standardized protocol.
  • Web Services Requiring High Security: Applications that handle sensitive or confidential information, such as personal healthcare records, banking transactions, or secure corporate communications, can benefit from SOAP’s comprehensive security features when used in conjunction with additional WS-* standards, such as WS-Security.
  • ACID-Compliant Transactions: For applications where it is vital that a series of operations are completed successfully before any changes are committed, like in a banking transaction, SOAP's support for ACID-compliant transactions is invaluable. If any part of the transaction fails, the entire transaction can be rolled back to its initial state, ensuring data integrity.
  • Stateful Operations: While SOAP itself is stateless, it can be used to design stateful operations through additional standards such as WS-ReliableMessaging, which allows messages to be delivered reliably between distributed applications.
  • Asynchronous Processing and Invocations: Systems that need to support asynchronous method calls, where the client sends a request to the server and continues with its work (not requiring an immediate response), can use SOAP in conjunction with additional specifications like WS-ReliableMessaging.
  • Error Handling and Recovery: For applications that require robust error handling and recovery mechanisms, SOAP’s standardized fault model provides a consistent way to handle errors and exceptions.
  • Messaging Patterns beyond Request-Response: SOAP supports more complex messaging patterns, such as one-way messaging, where a sender application sends a message without expecting a response, or more complex patterns like publish/subscribe. These patterns are supported through additional WS-* standards.
  • Network-Neutral Communications: In cases where communication may occur over different network protocols (HTTP, SMTP, TCP, etc.), SOAP’s transport neutrality is a significant advantage, allowing the same service implementation to be reused across different transport protocols.
  • Service Orchestration: In scenarios where there is a need to coordinate and manage the interactions between different services and applications, SOAP can be used with standards like WS-Coordination and WS-AtomicTransaction to facilitate complex orchestration of services.
  • Legacy System Integration: SOAP is often used to expose the functionalities of legacy systems over the network, allowing newer systems to communicate with older, established systems. This helps to prolong the useful life of legacy systems by making their functions accessible to modern applications.
  • Third-Party Service Integration: Many third-party services, especially in the enterprise space (like certain CRM, ERP systems), expose their APIs as SOAP web services. For integration with these services, SOAP becomes a natural choice.
  • Government and Regulatory Compliance: In some cases, government or industry regulations may require the use of specific standards, which are often based on SOAP due to its strict specifications and extensive security features.

These use cases illustrate the versatility and robustness of SOAP as a protocol for web services, especially in environments where security, reliability, and complex transactions are a priority. However, it is worth considering the trade-offs, as SOAP can be more heavyweight and complex than other web service approaches, such as REST or GraphQL. The choice of SOAP or another protocol will depend on the specific requirements of the project or system in question.


Advantages of Simple Object Access Protocol (SOAP)

  • Standardization and Interoperability: SOAP is a protocol with a standard set of rules and specifications established by the World Wide Web Consortium (W3C). This ensures that diverse systems built with different technologies and programming languages can communicate and interact with each other in a standardized and predictable way.
  • Platform and Language Independence: SOAP allows for communications between different applications, irrespective of the operating system, programming language, or any other system-specific detail on which they are implemented. This independence is fundamental for building truly distributed systems.
  • Strong Security Features: SOAP, when used in conjunction with other WS standards like WS-Security, provides a robust security model. This includes a wide range of security features such as authentication, authorization, integrity checks through digital signatures, and confidentiality through encryption.
  • ACID-Compliant Transactions Support: SOAP can be used to ensure that a series of operations are executed as a single, atomic transaction that is either entirely completed or entirely rolled back, in line with the ACID (Atomicity, Consistency, Isolation, Durability) properties. This is crucial for applications like financial transactions.
  • Comprehensive Error Handling: SOAP messages have a built-in standard structure for errors called the SOAP Fault. This feature enables standardized error handling and makes it easier for developers to troubleshoot and handle exceptions gracefully.
  • Support for Synchronous and Asynchronous Communication: SOAP supports both synchronous and asynchronous operations. This flexibility allows for versatile communication scenarios, such as cases where an immediate response is necessary or where operations can be queued and executed later.
  • Extensibility: SOAP can be extended with additional protocols and technologies. This is typically achieved through the use of SOAP headers, which can contain additional, optional metadata pertinent to the request or response.
  • Strict and Strong Typing: SOAP uses XML Schema to define the data types of the information in its messages. This allows for detailed and precise specifications of the data structures that a SOAP message can contain and facilitates the validation of that data.
  • Support for Complex Operations: SOAP is designed to handle complex transactions and can be used to define intricate operations beyond simple CRUD (Create, Read, Update, Delete) functionalities. This makes it well-suited for enterprise-level applications where complex and multi-step transactions are common.
  • Built-in Retry Logic (WS-ReliableMessaging): With the WS-ReliableMessaging extension, SOAP can ensure message delivery through built-in retry logic, ensuring that messages are delivered reliably even under challenging network conditions.
  • Network-Friendly: SOAP is designed to work over multiple transport protocols, including HTTP, SMTP, TCP, and more. Its common use over HTTP/HTTPS makes it easy to use through existing firewalls and network infrastructure without requiring special adjustments.
  • Statelessness: SOAP, like HTTP, is stateless by nature, meaning that each message is an independent, self-contained transaction. This allows for scalability as each message carries all the information that is necessary to understand and process the request.
  • Wide Industry Adoption: Because of its standardized nature and robust features, SOAP has been adopted extensively, particularly in enterprise environments. This widespread adoption means that many existing systems and services are built with SOAP, making it a necessary and valuable skill for developers.


Disadvantages of Simple Object Access Protocol (SOAP)

  • Verbosity and Size: SOAP messages can be significantly larger than messages in other formats due to their extensive use of XML tags and the additional information (like headers) that they carry. This can lead to increased network traffic and longer transmission times, which might not be ideal for low-bandwidth or high-latency environments.
  • Complexity: SOAP is a fairly complex protocol, with a detailed set of standards and specifications. This can make it challenging to learn, implement, and debug, especially for new developers or for small, quick projects.
  • Performance Overhead: The parsing of XML in SOAP messages imposes a processing overhead on both the client and server. This can be a significant concern for services that require high performance and scalability, especially when dealing with a large number of simultaneous connections.
  • Not as Human-Readable as JSON: While XML, the foundation of SOAP, is human-readable, it is generally not as easy to read and write as JSON (JavaScript Object Notation), which is more compact and has become the de facto standard for many modern APIs.
  • Firewall and Security Issues: Some firewalls and security appliances may block SOAP messages due to the rigorous security rules applied to HTTP traffic. This can complicate deployments and may require additional configuration.
  • Difficulty with Asynchronous Operations: Although SOAP supports both synchronous and asynchronous operations, handling asynchronous operations can be more challenging in SOAP than in other protocols, adding to the complexity of the application.
  • Less Suitable for Mobile and Browser Applications: Due to its verbose nature and the processing power required to parse XML messages, SOAP might not be the best fit for mobile or browser applications where bandwidth and performance are critical concerns.
  • Limited Method Support in HTTP Transport: When used with HTTP, SOAP typically relies on just two HTTP methods: POST and occasionally GET. This makes it less natural for building RESTful services, which use a range of HTTP methods (e.g., GET, POST, PUT, DELETE) to map CRUD (Create, Read, Update, Delete) operations to HTTP requests.
  • Challenges with Cross-Domain Requests: Making SOAP requests from a web application to a server on a different domain can be problematic due to browser security restrictions, known as the same-origin policy. Handling cross-origin resource sharing (CORS) with SOAP can be complex and require additional server configuration.
  • Dependency on Additional WS- Standards: For many advanced features (such as security, transactions, and messaging patterns), SOAP relies on additional WS-* standards, which can add to the complexity and learning curve for developers.
  • Stateless Nature: The stateless nature of SOAP, like HTTP, means that each transaction is independent. For applications that require maintaining a continuous or complex conversation with the client, developers may need to implement additional layers or mechanisms, such as session management, complicating the application’s design.
  • Limited Community and Tooling for Modern Development: As REST and GraphQL have gained in popularity for public APIs and mobile application development, the community, tooling, and third-party support have shifted somewhat. This can make it harder to find up-to-date resources, tools, and community support for SOAP compared to newer protocols.

These disadvantages don't necessarily make SOAP a poor choice, but they do illustrate where SOAP might not be the best fit. It is still heavily used in many enterprise environments and industries, such as healthcare and finance, where its advantages in terms of security, transactions, and standardization are highly valued. The choice between SOAP and other web service protocols typically depends on the specific needs of the application and the environment in which it operates.


See Also

Enterprise Service Bus (ESB)
Service Oriented Architecture (SOA)
Enterprise Integration
Enterprise Architecture
Representational State Transfer (REST)