Skip to main content

Should the service be Stateless or Stateful

A stateless system can be seen as a black box where at any point in time the value of the outputs depend only on the value of the inputs.

A stateful system can be seen as a box where at any point in time the value of the outputs depend on the value of the inputs and of an internal state. So basically a stateful system is like a state machine with memory as the same set of inputs can generate different outputs depending on the previous inputs received by the system.

This is an important distinction to make when deciding on a type of service. If your service needs to be stateful then SOAP is the type of service you need. A real world example of where SOAP is preferred over REST can be seen in the banking industry where money is transferred from one account to another. SOAP would allow a bank to perform a transaction on an account and if the transaction failed, SOAP would automatically retry the transaction ensuring that the request was completed. Unfortunately, with REST, failed service calls must be handled manually by the requesting application.

Did this page help you?

If you find any issues with this page or its content – a typo, a missing step, or a technical error – let us know how we can improve!