Glossary
Last Updated Jul 06, 2021

SOAP API

Emma Jagger
Emma Jagger

Table of Contents:

Get your free
 API key now
stars rating
4.8 from 1,863 votes
See why the best developers build on Abstract
START FOR FREE
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
No credit card required

What is a SOAP API?

SOAP API (Simple Object Access Protocol) is in some ways the predecessor to the REST API, but it is distinct from REST. SOAP vs REST simply put would be: SOAP is a protocol, while REST is a style.

The clearest analogy is in this Postman article, which compares SOAP to a National Postal Service: "(SOAP) is older, established, and dependable— but it can be slower than competing architectural styles like REST."

SOAP API requests and responses are formatted with XML, and while extensible, areand more bandwidth intensive than REST. Like REST, they are transmitting with HTTP, but can also use SMTP, TCP, and UDP, which can be a big benefit in the right use cases.

What are the parts of a SOAP API?

While XML allows for data to be described any way you like, the SOAP schema requires a specific structure around that data.

  • Envelope: This part identifies the message as a SOAP message.
  • Header: Information about the message. Think of the header as metadata for the message, like authentication details. If it were a real-world letter, it may contain the recipient, sender, and postage details. The header is optional.
  • Body: The content of the message. This area is used for both the API query / request and the API payload / response —depending on the direction of the message.
  • Fault: This part stores information about any errors that occur in the request or response. The fault is contained within the body when an error occurs. It is also optional.

Are SOAP APIs obsolete?  

Not at all. While REST API's are common (e.g., all Abstract's APIs use REST), SOAP is still widely used, especially in enterprise and banking applications, where the strict contracts of XML schema maintain stability and structure in responses and requests. It requires more bandwidth to transmit verbose XML states with every request, but is a worthwhile tradeoff for security and functionality.

Conclusion

REST APIs are extremely popular, but SOAP APIs do offer a lot of functionality out of the box that REST APIs do not. They are also a good place to start if you are just learning web development, because their stricter formatting requirements are more instructional than REST, akin to learning C++ before learning Python.

Frequently Asked Questions

What is a SOAP API?

SOAP (Simple Object Access Protocol) is a protocol for exchanging structured information between applications. It predates REST and uses XML to format its requests and responses, making it an older but established and dependable way to build APIs.

How does a SOAP API work?

A SOAP API sends and receives messages written in XML that follow a strict structure. Each message is wrapped in an Envelope that identifies it as SOAP, with an optional Header for metadata, a Body containing the actual request or response, and an optional Fault element for error information.

What protocols can SOAP use to transmit messages?

SOAP most commonly uses HTTP, like REST. However, it can also transmit messages over SMTP, TCP, and UDP, which gives it flexibility in certain scenarios.

What is the difference between SOAP and REST APIs?

REST APIs are more common and use less bandwidth than SOAP, which relies on verbose XML. SOAP, in turn, provides a lot of functionality out of the box that REST does not, and its strict XML schema enforces stable, well-defined requests and responses.

When should you use a SOAP API?

SOAP is widely used in enterprise and banking applications, where the strict contracts of its XML schema keep requests and responses stable and structured. Its stricter formatting is also valuable when security and clear structure are priorities.

What are the advantages and disadvantages of SOAP?

SOAP's main advantage is the structure and stability provided by its strict XML schema, along with built-in functionality that REST lacks. Its main drawback is that the verbose XML format requires more bandwidth and is generally slower than REST.

Get your free
API
key now
stars rating
4.8 from 1,863 votes
See why the best developers build on Abstract
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
No credit card required