Differences between web service and HTTP callouts from Apex
Apex callouts come in two flavors.
- Web service callouts to SOAP web services use XML, and typically require a WSDL document for code generation.
- HTTP callouts to services typically use REST with JSON.
These two types of callouts are similar in terms of sending a request to a service and receiving a response. But while WSDL-based callouts apply to SOAP Web services, HTTP callouts can be used with any HTTP service, either SOAP or REST.
When to Use HTTP & SOAP:
Whenever possible, use an HTTP service. These services are typically easier to interact with, require much less code, and utilize easily readable JSON.
Use SOAP mostly when integrating with legacy applications or for transactions that require a formal exchange format or stateful operations.
- SOAP callouts use XML and may use a WSDL for code generation.
- HTTP callouts typically use JSON but can use XML as well.
- HTTP callouts are generally easier to work with than SOAP callouts.
SOAP Web Services are commonly used for Enterprise apps that require a formal exchange format or stateful operations.