1

I am new to the concept of web services but i have gone through few atrticles and have implemented REST services. I have few questions

  1. Are web services used only in the case of cross-platform communication?

  2. When to use SOAP or REST? How do i make the decision

  3. What are the advantages of web services

Thanks in advance

DPH
  • 261
  • 4
  • 16
  • Please read [this](http://stackoverflow.com/questions/2131965/main-differences-between-soap-and-restful-web-services-in-java) and [this](http://stackoverflow.com/questions/2013793/web-services-vs-ejb-vs-rmi-advantages-and-disadvantages) – udalmik Aug 12 '14 at 07:59

1 Answers1

5

Before you spend hours fretting over the choice between SOAP and REST, consider that some Web services support one and some the other. Unless you plan to create your own Web service, the decision of which protocol to use may already be made for you. Extremely few Web services, such as Amazon, support both. The focus of your decision often centers on which Web service best meets your needs, rather than which protocol to use.

SOAP is definitely the heavyweight choice for Web service access. It provides the following advantages when compared to REST:

Language, platform, and transport independent (REST requires use of HTTP)
Works well in distributed enterprise environments (REST assumes direct point-to-point communication)
Standardized
Provides significant pre-build extensibility in the form of the WS* standards
Built-in error handling
Automation when used with certain language products

REST is easier to use for the most part and is more flexible. It has the following advantages when compared to SOAP:

No expensive tools require to interact with the Web service
Smaller learning curve
Efficient (SOAP uses XML for all messages, REST can use smaller message formats)
Fast (no extensive processing required)
Closer to other Web technologies in design philosophy
Bhumin Vadalia
  • 271
  • 1
  • 5
  • Note that REST in the form of the JAX-RS API also has built-in and very extensible error handling (and validation) routines. I wonder what "built-in" error handling you speak of in the context of the SOAP specification. A definite benefit of REST is also that it is more portable, when using SOAP you run a risk of running into incompatibilities due to the specification historically being very poorly defined. Remember the victory it was that JAX-WS could talk to a .NET webservice for example. – Gimby Aug 12 '14 at 08:25