Java – how can restful web services be better than soap based web services

I have experienced various websites, and the only answer they provide is – restful web services use HTTP's own methods, such as (get, post, put, delete) Soap - based web services use their own custom methods

However, I do not understand the full meaning of these answers As for why these things have proved to have such advantages over Soap - based web services

An example would be appreciated

Solution

Rest is naturally suitable for Web / cloud APIs, while soap is suitable for distributed computing scenarios

Bandwidth is the main advantage of rest because there is no complex document traversal (i.e. XML, soap header), which is very important for a good web API JSON is a widely recognized and simple standard for data exchange, and can be easily read through browser and client code, which is why most restful APIs (Yahoo is a good example) provide JSON

Not to mention that rest can be used for XMLHttpRequest objects, which is also crucial to the Ajax capabilities of Web APIs

Of course, the cache function of rest can't be ignored Because rest is based on HTTP, you can use many semantics of HTTP (and the web itself) to enable browser caching by using the header on HTTP packets (expires) Not to mention gzip compression to improve efficiency In terms of performance, rest is actually done through soap

For soap, soap applies to state operations Ws * standards (security, transaction processing, etc.) deal with this kind of pipeline which is quite common in distributed scenarios You can use rest to complete rest, but it won't really be rest Soap is very useful for defining the operation contract between client and server, which is very important in distributed scenarios

Therefore, my opinion (and the whole soap and rest thing) is highly praised. Soap is used in distributed computing scenarios and rest is used in Web APIs

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>