REST vs SOAP Web Services [closed]
I am seeing a lot of new web services are implemented using a REST style architecture these days rather than a SOAP one.
what is the difference开发者_Go百科?
There is no such thing as one being better, they are different and what is better depends on your needs.
If you need a lot of standards based functionality with relatively rich clients SOAP will deliver that. It gives thinks like metadata, WSDL, security or reliable messaging to name but a few through the WS-* specs. It is also transport agnostic and completely XML centric.The flip side of the coin is that there is a big standard that is not always implemented in an interopable fashion.
REST on the other hand is all about HTTP and its way of doing things. Very flexible and allows any kind of data format you like. So not just XML but also SOAP, images or VCards to name a few. It embraces the web standards so will work with almost any programming stack. The flip side is far fewer standards so it can be much harder to figure out how to do something.
An advantage of REST over SOAP is that the action is specified by the HTTP method and by the URL, this means that fewer bytes have to be sent as compared to SOAP which relies on verbose XML. And fewer bytes means less latency; therefore, I would recommend using REST instead of SOAP.
精彩评论