Simple Object Access Protocol (SOAP) and REpresentational State Transfer (REST) both enable access to web services, and both are based on well-established and agreed-upon rules to enable the exchange of information. REST is newer than SOAP, and was created to fix problems in SOAP and to provide a simpler interface to web services.
However, both SOAP and REST have issues, and often the decision about which one to use depends on which web service is in use because very few web services support both. One way to help you decide is to try them both against a number of free web services.
At the high level:
- SOAP is a more rigid set of messaging patterns than REST. The rules in SOAP are important because without these rules, you cannot achieve standardization.
- REST as an architecture style does not require processing and is naturally more flexible.
|Advantages to SOAP Compared to REST||Advantages to REST Compared to SOAP|
|Language, platform, and transport independent.||Requires HTTP|
|Works well in distributed enterprise environments||Assumes direct point-to-point communication|
|Standardized||Easier to use and more flexible|
|Built-in error handling||No expensive tools required|
|Pre-Built extensibility through web services||Fast because there is no extensive processing required|
|Automation when used with certain languages||Closer to other web technologies in design philosophy|
|Uses XML for all messages||Uses smaller message formats for efficiency|
- SOAP is highly extensible, which means you use only the modules you need for a particular application.
- A Web Services Description Language (WSDL) provides the definition of how the web service works. This means that when you create a reference to this file, the IDE can completely automate the process.
- Built-in error handling makes it easier to handle problems. For example, if there is a problem with the request, the response contains error information, which is very important if you do not own the web service. The error reporting also provides standardized codes so you can automate some error handling tasks in your code.
- You do not have to use SOAP with HTTP transport. There is a specification for using SOAP over Simple Mail Transfer Protocol (SMTP) and you can also use it over other transports.
REST is lighter weight. Requests use a simple URL in many cases instead of XML. There are situations where you must provide additional information in special ways, but most web services that use REST rely exclusively on obtaining the needed information with the URL approach.