27

I don't have any reference to give here to show my research (because none of the links are to the point) and even Google doesn't have an exact answer. Everyone says web service is stateful but that's confusing. By principle, I believe, SOAP is stateful and REST is stateless. So, Why/How SOAP is stateful ?

kSO
  • 305
  • 1
  • 4
  • 8
  • 5
    You can do stateless SOAP and stateful REST. – David Brabant Apr 22 '16 at 07:13
  • 1
    @David Brabant : So, can we say that being stateful is not one of the principles of SOAP ? I am asking this because being stateless is one of the 6 principles of REST and I found people saying SOAP as stateful while comparing with REST. – kSO Apr 22 '16 at 21:43

2 Answers2

31

Basically Stateful means that server stores information about the client and uses that information over a series of requests. So performing one request is dependant upon the state of some other request (e.g. previous). Implementing this is possible with http protocols.

So you can have stateful or stateless SOAP - it's only a matter of how you design it.

Also please note that comparing SOAP and REST is not really correct. The first one is basically Protocol (or at least it's trying to be) and REST is just a architecture pattern/style.

I know this is not exactly answering your question but please take a look at this link: SOAP vs REST (differences) It's extremely well written and can help you understand those technologies a bit better.

Community
  • 1
  • 1
Wazniak
  • 501
  • 5
  • 11
  • So, can we say that being stateful is not one of the principles of SOAP ? I am asking this because being stateless is one of the 6 principles of REST and I found people saying SOAP as stateful while comparing with REST. – kSO Apr 22 '16 at 21:42
  • @kSahoo yes, being stateful is **not** one of SOAP protocol principles or ideas behind it. – Wazniak Apr 24 '16 at 14:08
1

First off, SOAP is protocol. In other way we have services like REST, WSDL, WCF and many more. SOAP can be used as protocol in all kind of services. This mean, soap provide mechanism to pass data between client and server.

By design and main purpose SOAP is data protocl to be use between server and clients. Server(service) save, preserve and response data. Soap as data can be used in both variants in service - stateful or stateless.

By default soap service is stateless. For example WSDL soap service is stateless. Simple WebAPI, REST. They are all stateless.

WCF - Single Instance is stateful. WCF - Per call is stateless.

Being stateful is not one of SOAP protocol principles or ideas behind it. Service can be stateful or stateless.

Pit
  • 395
  • 2
  • 11