Kesha Williams introduces Simple Object Access Protocol, or SOAP.
- One alternative to RESTful APIs is to use SOAP. SOAP stands for Simple Object Access Protocol. It's a messaging protocol that uses XML to allow applications running on different systems or platforms to communicate. SOAP can carry a bit more overhead. It allows for additional security, different kinds of transactions, and ACID compliance. ACID stands for Atomicity. Consistency, Isolation, and Durability.
These are the qualities you need when you're processing complex or important operations. For example, if you're moving money from one account to another, you want to make sure that the money is taken out of one account and put in the other. If either of those transactions fails, then neither should happen. If you're curious to learn more about ACID, I'd encourage you to take a look at the Programming Foundations course on working with databases. SOAP also defines a set of rules for structuring messages and security.
In SOAP, the WSDL file gives the client information on what services the web service can offer. Imagine going to an ice cream shop. You're able to see several delicious flavors behind the glass, but you're not allowed to go behind the glass. The employee has to go behind the glass, make your ice cream cone, and hand it to you, and you have to pay. But in this ice cream shop, you only get your ice cream cone if you ask for it the right way.
Let's say the proper protocol and message format is, but then you ordered like this. Then your request cannot be fulfilled, and you end up with no ice cream. And that is what the WSDL document is for. WSDL stands for Web Service Description Language, and it tells the client of all the operations that can be performed by the web service. It's kind of like a guide for ordering ice cream, or the information you want to get back.
The WSDL will contain all the information you need, like the data types being used in the SOAP messages, and a list of all the operations available via the web service. SOAP specifications are official web standards maintained and developed by the W3C, the World Wide Web Consortium. SOAP messages themselves have multiple parts. The data being shared is placed in what's called an envelope. The envelope is, in fact, an ordinary XML file that consists of the specific parts and has a specific structure, rules for encoding, invocations, and responses, and are often transmitted over HTTP.
There are four parts to a SOAP message. The envelope is required. It's the starting and ending tags of the message. The header is optional. It contains the attributes of the message. It allows you to extend a SOAP message by adding additional information like security tokens. The body is required. It contains the actual XML data that the server transmits to the receiver. And last, the fault, which is optional.
The fault carries information about any errors that might occur during processing the message. SOAP messages will look different depending on the implementation, but they'll always carry the same parts in the same order.
- What is a web service?
- Securing web services
- Consuming and creating a RESTful API
- Documenting an API
- Creating a web service
- Consuming a SOAP web service
- Developing APIs using GraphQL