What is SOAP API?

Overview

SOAP API (Simple Object Access Protocol) is a protocol specification for exchanging structured information in web services using XML. It defines a set of rules for requesting and responding to remote procedure calls over HTTP or other application layer protocols. In the context of Salesforce, the Salesforce SOAP API exposes Salesforce data and functionality through SOAP-based web services, enabling integrations with enterprise systems, middleware, and legacy applications.

Key Concepts

SOAP API relies on several core concepts:

  • XML-based messaging: Requests and responses use XML documents structured according to the SOAP standard.
  • Envelope: The SOAP envelope wraps the message and defines the start and end of the message.
  • WSDL (Web Services Description Language): A machine-readable XML description of available operations, message formats, and endpoints. Clients generate proxies from the WSDL to call the service.
  • Operations: Defined methods/actions exposed by the service (e.g., query, create, delete).
  • Headers: SOAP headers can carry metadata such as authentication tokens (e.g., sessionId) or transactional information.

Typical SOAP Envelope (Example)

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:partner.soap.sforce.com">
<soapenv:Header>
<urn:SessionHeader>
<urn:sessionId>00Dxx0000001gPFEAY!AQsAQ...</urn:sessionId>
</urn:SessionHeader>
</soapenv:Header>
<soapenv:Body>
<urn:query>
<urn:queryString>SELECT Id, Name FROM Account LIMIT 10</urn:queryString>
</urn:query>
</soapenv:Body>
</soapenv:Envelope>

Benefits

  • Strong typing and formal contracts via WSDL makes client generation, validation, and tooling straightforward.
  • Built-in extensibility: headers for authentication, sessions, or custom metadata.
  • Well-suited for enterprise integrations and systems that rely on SOAP-based middleware.

SOAP API vs REST API

Both SOAP and REST enable integration, but they differ:

  • Protocol: SOAP is a protocol with formal standards (XML envelopes, WSDL). REST is an architectural style using standard HTTP methods and usually JSON.
  • Payload: SOAP uses XML; REST typically uses JSON (or XML).
  • Tooling: SOAP provides WSDL-based client generation; REST often relies on lightweight SDKs or HTTP clients.
  • Use cases: SOAP is preferred for legacy enterprise systems and strict contracts; REST is preferred for modern web/mobile apps due to lightweight payloads.

Using Salesforce SOAP API

Common steps when integrating with Salesforce via SOAP API:

  1. Download the WSDL (Enterprise or Partner) from Salesforce Setup.
  2. Generate client stubs in your language (Java, .NET, PHP) using WSDL-based tools.
  3. Call the login operation or include OAuth sessionId in the header to authenticate.
  4. Use operations like query, sObject create/update/delete, and describeSObjects to interact with metadata and data.

Limitations & Best Practices

  • SOAP messages can be verbose due to XML — consider REST for mobile/low-bandwidth scenarios.
  • Be mindful of Salesforce API limits and bulk APIs when processing large data volumes.
  • Use HTTPS and follow secure authentication patterns (avoid plain-text credentials; prefer OAuth when possible).
  • Cache WSDL-based clients where appropriate; regenerate clients when the WSDL changes.

Conclusion

The SOAP API is a mature, contract-driven web service standard ideal for enterprise integrations and legacy systems that require strong typing and formal WSDL contracts. In Salesforce integrations, SOAP remains valuable where generated client proxies, complex enterprise middleware, or strict service contracts are required.