0

I have read lot a whats are difference b/w soap and restful web services. I have got specific doubts for which i did not get answers. Here they are :-

What goes in favor of Restful web services In nutshell everybody seems to be preferring Restful web services over soap. main reason behind it easy to develop and understand. Also faster mainly because of light weight data exchange format like json. Also in Performance in restful web services is better because less data is traveled over network(Soap involves extra layer of saop message under http request). So far so good.

Accepted answer at how is Restful web services better than SOAP based webservices also says

REST naturally fits for Web/Cloud API's, whilst SOAP fits for distributed computing scenarios.

I did not get whats the difference between Web and distributed computing scenarios. Web is also case of distributed computing scenarios. Is n't it ? so how come one is better for web while another is for distributed scenarios ? (Q1)

What goes in favor of SOAP :-

Same answer also says that SOAP caters for stateful operations. As per my understanding its not true. If you need to maintain the state you need to maintain thru you code like sending some unique ID in both request/response that relates them Is n't it? (Q2) If thats the case that can be done in restful web services also.

Some says SOAP is better in terms of security. I don't what security soap provides that rest does not? (Q3)

Soap is probably is better in one sense that it has WSDL(that too generated by tools) doc thru which clients can generate their respective stubs. In restful webservices developer has to create the comprehensive doc himself so that client knows about the input request parameters. correct ? (Q4)

Note :- I have referred Q for question(Q1 is Question1)

Community
  • 1
  • 1
M Sach
  • 33,416
  • 76
  • 221
  • 314

2 Answers2

1

There are 3 reasons to prefer REST over SOAP

  1. Resources have URLS that identify them. If you want to share the result of some API operation with a friend, then you don't have to instruct them verbally on which API method to call and which parameters to pass. Instead, you can just share with him the URL. (for safe operations only). A great example is restaurant sites that are built in flash. If you just want to share with a friend the menu of the restaurant, you can't do that very easily. You can only tell him which buttons to press when the flash page loads.

  2. With REST you can take advantage of the existing HTTP infrastructure on the internet to do a lot of work, i.e. caching, resource conflict management, and so on. You don't have to reinvent the wheel.

  3. Related to #2, many developers are already used to working with REST architectures. If you use REST you significantly cut down on the learning curve that new devlopers will have to incur when learning how to use your service.

gilsho
  • 921
  • 7
  • 11
  • How rest helps in caching/resource conflict management while soap does not? – M Sach Jun 01 '14 at 03:38
  • you can use the 'Cache-Control' header. Clients such as web browsers know how to handle it. For resource management you can read the value of the 'If-Modified-Since' header provided by most clients and return a '304 Not modified' response if there hasn't been a change in the state of the resource. As for conflict management per se, REST won't help you solve that, but certainly gives you a framework to deal with it. See the 'Etag / If-None-Match' header and 'Last-Modified/If-Unmodified-Since' headers. http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html – gilsho Jun 01 '14 at 03:48
0

REST is cache-able for GET request. For SOAP, when using HTTP as the transfer mechanism, is sent via HTTP POST requests which are not cache-able.

M Sach
  • 33,416
  • 76
  • 221
  • 314