SOAP or REST?

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

How much more difficult it is to use SOAP compared to REST depends on which language you use. SOAP relies exclusively on XML to provide messaging services because XML works better over the internet than binary messaging does.  Some languages make it very easy to handle the XML, but in other languages, you must build the XML requests manually, which can be very complex and time consuming. For example, working with SOAP in JavaScript means you write a lot of code to perform simple tasks because you must create the required XML structure every time.

  • 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

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.

You can obtain the output you need in a form that is easy to parse within the language you need for your application. You can find REST-based web services that output the data in comma-separated value (CSV) format, JavaScript Object Notation (JSON), and Really Simple Syndication (RSS) feeds.

Advertisements
SOAP or REST?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s