Dev tools
REST vs SOAP: Key Differences for API Design
REST vs SOAP compared: protocol vs style, XML vs JSON, WSDL contracts, WS-Security, performance, real request examples and when each still makes sense.
In REST vs SOAP, SOAP is a strict messaging protocol: every message is an XML envelope, the service is described by a formal WSDL contract, and standards like WS-Security add message-level security and reliability. REST is an architectural style: it uses plain HTTP methods on resource URLs and usually sends lightweight JSON. REST is simpler, faster to build and the default for new web and mobile APIs; SOAP survives where formal contracts and built-in enterprise standards matter, such as banking, telecom, government and older enterprise systems.
This guide covers the REST vs SOAP API question in depth: the difference between REST API and SOAP API in a side-by-side table, a SOAP API example next to the same call in REST, SOAP vs REST performance with real byte counts, security, and a checklist for which to choose.
REST vs SOAP at a Glance
| SOAP | REST | |
|---|---|---|
| What it is | A protocol, standardized by the W3C (SOAP 1.2) | An architectural style described by Roy Fielding |
| Message format | XML only, wrapped in an Envelope | Any format; usually JSON, also XML, HTML, plain text |
| Contract | WSDL file describes every operation and type | Optional; OpenAPI is the common choice |
| Transport | Usually HTTP; also SMTP, JMS and others | HTTP |
| HTTP methods | Almost always POST to one endpoint | GET, POST, PUT, PATCH, DELETE on many URLs |
| Operations | Named operations (verbs), such as GetOrder | Resources (nouns), such as /orders/981 |
| State | Can support stateful operations via WS-* standards | Stateless by design |
| Caching | Not cacheable by HTTP caches (POST) | GET responses cacheable by browsers, proxies and CDNs |
| Security | Transport security plus WS-Security for message-level signing and encryption | HTTPS plus tokens (OAuth 2.0, API keys, JWT) |
| Errors | SOAP Fault element in the body | HTTP status codes plus an error body |
| Extra standards | WS-Security, WS-ReliableMessaging, WS-AtomicTransaction, WS-Addressing | None required |
| Tooling | Generated clients from WSDL; SoapUI | curl, Postman, browser, every HTTP library |
| Typical use | Banking, payments, telecom, government, legacy enterprise integration | Public APIs, web and mobile apps, microservices |
What Is SOAP?
SOAP is a protocol for exchanging structured messages between systems, using XML. It started at Microsoft and partners in the late 1990s, and the W3C published SOAP 1.2 as a Recommendation in 2003, with a second edition in 2007. The name originally stood for Simple Object Access Protocol, but the SOAP 1.2 specification says plainly that "the SOAP name was an acronym. This is no longer the case."
Every SOAP message has the same structure, defined by the spec:
- Envelope: the root element that marks the XML as a SOAP message.
- Header: optional; carries metadata such as security tokens, transaction IDs or routing information. Header blocks can be marked as mandatory.
- Body: required; carries the actual request or response.
- Fault: a special element inside the Body used to report errors, with a required code and reason.
A SOAP service is usually described by a WSDL (Web Services Description Language) file. WSDL is a machine-readable contract that lists every operation, its input and output messages and the XML types involved. Tools read the WSDL and generate client code, so a Java or .NET developer can call a SOAP service like a local method.
Around SOAP grew a family of standards known as WS-\*: WS-Security for signing and encrypting messages, WS-ReliableMessaging for guaranteed delivery, WS-AtomicTransaction for distributed transactions, WS-Addressing for routing. These are SOAP's real selling point in enterprise settings: features that REST leaves to each team to build.
What Is REST?
REST (Representational State Transfer) is an architectural style that Roy Fielding defined in his 2000 doctoral dissertation. It's a set of constraints rather than a protocol: client and server are separate, requests are stateless, responses declare whether they can be cached, the system can be layered with proxies in between, and all resources are reached through a uniform interface.
A REST API exposes resources at URLs and acts on them with HTTP methods. GET /orders/981 reads an order, POST /orders creates one, PATCH /orders/981 updates it and DELETE /orders/981 removes it. Responses carry an HTTP status code (200, 201, 404, 429) and usually a JSON body.
REST has no required contract format. Many teams publish an OpenAPI document to describe endpoints and schemas and generate clients from it, which gives REST some of the tooling SOAP had through WSDL, but it's optional.
The Difference Between REST API and SOAP API
The table above lists the differences; here's what they mean in practice.
Protocol vs style
SOAP is a protocol with a specification: a message either follows it or doesn't. REST is a style: two REST APIs can look quite different and both be called RESTful. SOAP's rigidity is good for interoperability between large organizations that never talk to each other's developers. REST's flexibility is good for speed and simplicity.
XML only vs any format
SOAP requires XML. REST can send anything, and in practice it sends JSON, which is shorter, maps directly onto objects in JavaScript, Python and most modern languages, and is easier for people to read.
One endpoint and POST vs many URLs and methods
A SOAP service typically exposes one URL and every call is an HTTP POST; the operation name lives inside the XML. REST uses the URL and method to say what's happening. That's why REST works with HTTP caching, browser address bars and standard logs, and why a SOAP call looks the same to any proxy whether it reads or deletes data.
Built-in standards vs build your own
SOAP brings standard answers for message signing, encryption, reliable delivery and distributed transactions. REST has no equivalents in the style itself; teams use HTTPS, OAuth 2.0, idempotency keys and retry patterns instead. For most applications these are enough, and simpler.
Errors
SOAP reports errors with a Fault element whose code and reason are defined by the spec. REST uses HTTP status codes, which every developer knows, plus an error body in whatever format the API chooses. Our guide to API rate limiting shows how one of those codes, 429, works in practice.
SOAP API Example
Here's a SOAP API example: a client asks an order service for order 981. The request is an HTTP POST with a SOAP 1.2 envelope in the body. SOAP 1.2 messages use the application/soap+xml media type.
POST /OrderService HTTP/1.1
Host: api.example.com
Content-Type: application/soap+xml; charset=utf-8
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:m="https://example.com/orders">
<soap:Body>
<m:GetOrder>
<m:Id>981</m:Id>
</m:GetOrder>
</soap:Body>
</soap:Envelope>The response comes back in the same envelope structure:
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:m="https://example.com/orders">
<soap:Body>
<m:GetOrderResponse>
<m:Order>
<m:Id>981</m:Id>
<m:Status>shipped</m:Status>
<m:Total>42.50</m:Total>
</m:Order>
</m:GetOrderResponse>
</soap:Body>
</soap:Envelope>The same call in REST:
GET /orders/981 HTTP/1.1
Host: api.example.com
Accept: application/json{"id":981,"status":"shipped","total":42.5}The REST version is one line of request and one line of response. The SOAP version is more verbose, but notice what you get in exchange: the namespaces and operation names are defined in the WSDL, a code generator can produce typed classes for Order, and the Header element is available for security tokens or transaction context without changing the body.
SOAP vs REST Performance
REST with JSON is usually faster and lighter than SOAP, mainly because XML envelopes are larger and slower to parse. How much it matters depends on the volume.
Using the example above:
| Response | Size in bytes |
|---|---|
| SOAP 1.2 envelope, as formatted above | 370 |
| SOAP envelope with whitespace removed | 310 |
| REST JSON body | 42 |
For this small message, the SOAP response is about seven times the size of the JSON one, even with whitespace stripped. The gap shrinks for large payloads where the data itself dominates, and gzip compresses repeated XML tags well, but parsing XML with namespaces still costs more CPU than parsing JSON.
Where the difference shows up:
- High request volumes. Thousands of calls per second multiply the parsing cost.
- Mobile clients. Smaller payloads mean less data and battery.
- Caching. REST GET requests can be served from a CDN or browser cache without reaching your server at all; SOAP POST requests can't.
Where it doesn't: a few calls per minute between two back-office systems, where reliability and auditability matter more than milliseconds.
Security: REST vs SOAP
Both can be secure. They put the security in different places.
SOAP can use HTTPS for transport security, and it can also secure the message itself with WS-Security, an OASIS standard first approved in 2004. WS-Security signs and encrypts parts of the XML, so the message stays protected even if it passes through intermediaries, queues or logs. That end-to-end, message-level protection is one reason banks and payment networks adopted SOAP.
REST relies on HTTPS for transport security and on tokens for authentication: OAuth 2.0 access tokens, API keys or signed JWTs. When a REST API needs to prove a message wasn't altered, it adds request signing (for example an HMAC signature header, as many payment and cloud APIs do). Webhooks use the same idea; our explainer on webhook vs API covers signature checks.
For most applications, HTTPS plus OAuth 2.0 is enough. If you have a regulatory requirement for message-level signing that survives intermediaries, SOAP's standards give you a tested way to do it.
Where SOAP Is Still Used
SOAP isn't dead; it's concentrated in places where systems last decades.
- Financial services and payments: many bank, card and insurance integrations still use SOAP services.
- Telecom and government: procurement rules and long-lived systems favor formal contracts.
- Enterprise platforms: Salesforce, for example, offers both a SOAP API and a REST API; its documentation describes SOAP API's WSDL as a formal contract that suits server-to-server integrations, while most of the same functionality is also available through REST.
- Legacy integrations: ERP systems and internal services built in the 2000s on Java and .NET web service stacks.
New public APIs are overwhelmingly REST (or GraphQL and gRPC for specific needs). If you're starting fresh, you'll choose SOAP only when a partner requires it or when you specifically need the WS-* standards.
REST vs SOAP vs Other API Styles
REST and SOAP are no longer the only choices.
| Style | Format | Best for |
|---|---|---|
| SOAP | XML envelope, WSDL contract | Formal enterprise integrations, message-level security |
| REST | Usually JSON over HTTP | Public APIs, web and mobile apps |
| GraphQL | JSON, one endpoint, client-chosen fields | Front ends combining many data sources |
| gRPC | Binary Protocol Buffers over HTTP/2 | Fast internal service-to-service calls, streaming |
| MCP | JSON-RPC messages for AI tools | Letting AI agents use tools and data |
Interestingly, gRPC brings back several of SOAP's ideas, such as a strict contract file and generated clients, with a much lighter binary format. Our comparison of MCP server vs API shows how the newest style relates to REST.
Which Should You Choose?
Answer these questions:
| Question | Choose SOAP if | Choose REST if |
|---|---|---|
| Does a partner, bank or government system require it? | Yes | No |
| Do you need message-level signing or encryption that survives intermediaries? | Yes | HTTPS is enough |
| Do you need distributed transactions or guaranteed delivery standards? | Yes | You can use queues and idempotency instead |
| Who are the clients? | A few enterprise systems with generated clients | Browsers, mobile apps, many third-party developers |
| Does performance or caching matter? | Low volume, not critical | High volume, cacheable reads |
| What does the team know? | Java or .NET web service stacks | Modern web development |
Pick REST for almost every new web, mobile or public API. It's simpler, lighter, cacheable and supported by every tool.
Pick SOAP when you integrate with a system that only speaks SOAP, or when compliance requires WS-Security, reliable messaging or transaction standards and you'd rather adopt a standard than build your own.
Many companies use both: a SOAP integration to a bank or ERP behind the scenes and a REST API facing their own apps and customers, with a small service translating between them.
Common Mistakes
- Calling any HTTP+JSON API "REST". Many APIs are just RPC over HTTP; that's fine, but it explains why they don't cache or behave consistently.
- Rewriting a working SOAP integration for fashion. If a partner's SOAP service is stable, a thin adapter is cheaper than a rewrite.
- Ignoring the WSDL. Hand-writing SOAP XML instead of generating clients from the WSDL leads to namespace and type errors.
- Assuming REST is insecure. HTTPS plus OAuth 2.0 and request signing is a strong setup; SOAP isn't automatically safer.
- Mixing SOAP 1.1 and 1.2. They use different namespaces and content types (
text/xmlwith a SOAPAction header in 1.1,application/soap+xmlin 1.2); a mismatch causes confusing faults.
FAQ
Is SOAP faster than REST?
Usually not. SOAP messages are XML envelopes that are larger and slower to parse than JSON, and SOAP requests can't use HTTP caching. REST with JSON is generally lighter and faster.
Is SOAP still used?
Yes, mostly in banking, payments, telecom, government and older enterprise systems, and in platforms like Salesforce that offer SOAP next to REST. New public APIs rarely use it.
Can REST use XML?
Yes. REST doesn't require any format. It can return XML, JSON, HTML or plain text; JSON became the default because it's compact and easy to use in modern languages.
What is the main difference between REST and SOAP?
SOAP is a protocol with a fixed XML message format, a WSDL contract and optional enterprise standards. REST is an architectural style that uses HTTP methods on resource URLs with any format, usually JSON. SOAP is stricter; REST is simpler.
Is REST replacing SOAP?
For new APIs, largely yes. Existing SOAP services keep running because they work and are expensive to replace, so many organizations run both.