Are REST and SOAP enemies? [closed]

2019-08-27 19:30发布

问题:

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?

回答1:

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.



回答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]



标签: wcf rest soap