# When should architects select the SOAP API over the REST API for enterprise Salesforce integrations?

**Topic:** Integration · **Difficulty:** Medium · **Tags:** Integration, SOAP API, WSDL Contracts

Read it on the site: https://www.forcechallenges.com/interview-questions/when-should-architects-select-the-soap-api-over-the-rest-api-for-enterprise-salesforce-integrations

## Answer

**Basics:** SOAP exchanges XML envelopes over HTTP. A **WSDL** describes operations and data types, so tools generate client stubs automatically. Salesforce offers two WSDLs: **Enterprise** (strongly typed to your org's schema, tied to your org) and **Partner** (loosely typed, generic across orgs, good for ISVs and tools).

**How it works:**
1. Download the WSDL from Setup > API (Enterprise, Partner, Metadata, Apex-class-specific WSDL).
2. Generate client stubs in Java, .NET or an ESB tool.
3. Authenticate using an OAuth access token passed as the session ID in the `SessionHeader`. The username/password `login()` call is being retired, so verify its status in current release notes and migrate to OAuth.
4. Call operations such as `create`, `update`, `upsert`, `delete`, `query`, `queryMore`, `convertLead`, `merge`, `describeSObjects`.
5. The response is an XML result array; each record has a `success` flag and errors.

**Advanced / deep dive:** Real reasons to pick SOAP: (a) existing middleware or ERP connectors only speak WSDL; (b) compile-time type safety with the Enterprise WSDL; (c) SOAP-only features and calls (some `convertLead`/`merge` style operations also exist in REST now, so check); (d) the Metadata API and the Apex SOAP web services are SOAP. Drawbacks: verbose XML, heavier parsing, the Enterprise WSDL must be regenerated when the schema changes, and clients break on field deletions. Transaction control is the same as REST: each call handles up to 200 records, with the `AllOrNoneHeader` for all-or-nothing behavior. There is no distributed two-phase commit across systems. Both APIs use the same limits, sharing and FLS.

**Code / config example:**
```xml
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:urn="urn:enterprise.soap.sforce.com">
  <soapenv:Header>
    <urn:SessionHeader><urn:sessionId>ACCESS_TOKEN</urn:sessionId></urn:SessionHeader>
    <urn:AllOrNoneHeader><urn:allOrNone>true</urn:allOrNone></urn:AllOrNoneHeader>
  </soapenv:Header>
  <soapenv:Body><urn:query><urn:queryString>SELECT Id FROM Account LIMIT 1</urn:queryString></urn:query></soapenv:Body>
</soapenv:Envelope>
```

**Hidden gotchas & must-remember points:**
- A WSDL is a snapshot; regenerate the Enterprise WSDL after schema changes.
- Partner WSDL avoids regeneration but loses type safety.
- SOAP does not give you distributed transactions; saying so in an interview is a trap.
- SOAP and REST share the same API request limits.
- Older SOAP API versions are retired over time; track end-of-life announcements.
- Batches are capped at 200 records per call.

**Best practice:** Default to REST; choose SOAP only for a concrete reason such as WSDL-driven tooling, and authenticate with OAuth rather than passwords.

---
Source: ForceChallenges · last updated 2026-11-02
