0

Nowadays, REST is very popular on web community. So that I am curious to know these two questions.

  1. Are SOAP and REST enemies?
  2. Which one is better and why?
Joey
  • 344,408
  • 85
  • 689
  • 683
santosh singh
  • 27,666
  • 26
  • 83
  • 129
  • No idea of the technology involved here so take this qith a grain of salt: But usually it's better to ask two different questions as two different questions and not in one. But maybe both can be reasonably answered at once. – Joey Jan 30 '11 at 14:11
  • As I said, it may well be that they both are close enough to be answered at once – I just cannot tell since I couldn't give an answer. I just wanted to give the general way to do this as well :-) – Joey Jan 30 '11 at 14:16
  • Note that in CS there is no "better", just more appropriate for a certain scenario. Describe what you need specifically and we might be able to help you decide. – the_drow Jan 30 '11 at 14:43
  • @the_drow:I am agree with you that in CS there is no word "better".I have used word better in this context that if I have two method that performs same thing then which I will choose. – santosh singh Jan 30 '11 at 15:00
  • @santosh But without the problem's context there is no "better". – the_drow Jan 30 '11 at 15:07
  • possible duplicate of [SOAP or REST](http://stackoverflow.com/questions/76595/soap-or-rest) – Darrel Miller Jan 30 '11 at 17:38
  • This question has been asked and answered here so many times. – Darrel Miller Jan 30 '11 at 17:39

2 Answers2

4

They are not enemies, as they are for different purposes. REST is for lightweight communications, when you need a webservice attending a high number of petitions from a high number of clients, and you don´t need the server keep a state in the communication with each client.

SOAP on the other hand is more heavywieght, but includes some features not present in REST, like keeping a state, handling security, etc.

So each one will be better depending on the scenario.

Alejandro Martin
  • 5,691
  • 1
  • 17
  • 21
  • You can handle security with REST, however it depands on the protocol you are using. HTTP has an authentication machanism. – the_drow Jan 30 '11 at 14:33
  • For SOAP there are libraries that generate code to interface with existing systems – David W Jan 30 '11 at 16:18
  • That is because SOAP as a protocol provides type safety, However the code generation is done by a schema (WADL, WSDL etc.) and not by the SOAP protocol itself. – the_drow Jan 30 '11 at 17:16
2

REST is an architecture. SOAP is a protocol.
The main difference between the two is that REST utilizes the current protocol to perform it's actions and expose services to the clients. In case of the web this is HTTP but it can be used with any other protocol.
In fact SOAP in it's later and less common versions adopts some RESTful qualities (such as using HTTP Verbs instead of re-defining them at the envelope level).

[shameless-promotion]
I recommend you to take look at my presentation about web services. Also take a look at my question here that explains the difference between REST and RPC (SOAP is some form of RPC)
[/shameless-promotion]

Community
  • 1
  • 1
the_drow
  • 18,571
  • 25
  • 126
  • 193