Skip to main content

HTTP, REST and SOAP: Protocols Explained

"Is REST a protocol?" "Does SOAP use JSON?" "Is OAuth a data format?" — these questions come up constantly, and the confusion almost always comes from mixing up three separate layers.

Three layers people mix up​

LayerWhat it isExamples
TransportHow bytes actually travel between two machinesHTTP, HTTPS (HTTP + TLS encryption)
Style / protocolThe rules for structuring a request and responseREST, SOAP
Data formatHow the payload itself is encodedJSON, XML, CSV

REST and SOAP both usually travel over HTTP(S) — they're not alternatives to HTTP, they're built on top of it. And OAuth sits across all of these layers: it's neither a transport, a style, nor a format — it's how the caller proves who it is, regardless of which style or format you're using (more in Authentication Basics).

HTTP basics​

HTTP requests use a small set of methods, each with a conventional meaning:

MethodMeaning
GETRead a resource, no side effects
POSTCreate a new resource
PUT / PATCHUpdate an existing resource (PUT typically replaces, PATCH partially updates)
DELETEDelete a resource

Every response carries a status code, grouped into families:

  • 2xx — success. The request worked.
  • 3xx — redirect. The resource has moved; follow the new location.
  • 4xx — the caller's mistake. Something about the request itself was wrong.
    • 401 Unauthorized — no valid credentials were provided at all.
    • 403 Forbidden — credentials were valid, but you're not allowed to do this.
    • 404 Not Found — the resource doesn't exist (or you can't see that it does).
  • 5xx — server problem. The request was fine; the server failed to handle it.

REST vs SOAP​

REST is an architectural style, not a strict standard: every "thing" has a URL, and you act on it using HTTP methods. It's stateless (each request carries everything needed to understand it) and usually exchanges JSON.

SOAP is a stricter protocol: requests and responses are XML "envelopes" with a defined structure, the service's contract is described by a WSDL (Web Services Description Language) document, and it has built-in standards like WS-Security for things REST usually leaves to you.

The same request, two ways​

A REST GET to a simple public test API, /todos/1:

GET https://jsonplaceholder.typicode.com/todos/1

Response:

{
"userId": 1,
"id": 1,
"title": "delectus aut autem",
"completed": false
}

The same idea as a (simplified — real SOAP envelopes carry more XML scaffolding) SOAP request:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<GetTodoRequest>
<TodoId>1</TodoId>
</GetTodoRequest>
</soap:Body>
</soap:Envelope>

Comparison at a glance​

RESTSOAP
FormatUsually JSONXML only
ContractInformal (often OpenAPI/Swagger)Formal, machine-readable WSDL
WeightLighter payloadsHeavier, more scaffolding per message
ToolingBroad, simple HTTP tooling (Postman, curl, any HTTP client)Needs SOAP-aware tooling to generate/consume the WSDL
Typical usersModern web/mobile APIsEnterprise systems, legacy middleware, partners with existing SOAP contracts
In SalesforceREST API, Apex REST, Apex calloutsSOAP API, Apex SOAP services, WSDL2Apex-generated classes

A request and a response​

Rule of thumb​

Default to REST for new work. Reach for SOAP only when the other system only offers a SOAP endpoint, or a partner explicitly requires a WSDL contract.

Common mistakes​

  • Assuming a 404 throws a catchable error automatically. In Apex, an Http call that gets a 404 doesn't throw an exception by itself — HttpResponse.getStatusCode() just returns 404, and it's your code's job to check it. See Anatomy of a Request and Response.
  • Mixing up REST and JSON. REST is a style for structuring requests; JSON is just the format most REST APIs happen to use. You can technically build a REST API that returns XML.
  • Treating OAuth as a data protocol. OAuth governs authentication, not the shape of your payload — it's orthogonal to whether you're using REST or SOAP, JSON or XML.

Learn more on Trailhead​

Apex Integration Services covers calling and exposing REST and SOAP services from Apex.

For free, hands-on practice with real REST requests and responses, try JSONPlaceholder — a free fake API used throughout this course's examples.

Quiz​

Check your understanding

Question 1 of 5

Which layer does HTTP belong to?