Webservices are stateless?

后端 未结 5 916
灰色年华
灰色年华 2020-12-04 20:03

Why do we say that web services are stateless?

相关标签:
5条回答
  • 2020-12-04 20:14

    They don't persist any state between requests from the client. i.e. the service doesn't know, nor care, that a subsequent request came from client that has/hasn't made a previous request. Basically, its a 'give me this piece of info and forget about me' which puts the onus on the client to maintain any state.

    0 讨论(0)
  • 2020-12-04 20:15

    The concept of a web serivce is to model a RPC (Remote Procedure Call) aka a Function. Thus you should not need to use session. In addition, the idea of being stateless comes from the need to scale out web servers into a server farm and thus enable higher capacity.

    However, the choice of using state is dependant upon the technology and the developer. There is nothing to prevent you from creating an ASP.Net Web Service and setting "EnableSession=True" in the method definition.

    This can be useful in some basic authentication scenarios, i.e. home-grown forms authentication or to provide automatic correlation for short-lived "workflow"'s. (However I strongly urge you consider more modern techniques will provide a higher level of security and performance).

    0 讨论(0)
  • 2020-12-04 20:16

    Requests are independent from one another.

    0 讨论(0)
  • 2020-12-04 20:21

    Because HTTP is stateless. After a client request is fulfilled by the server, no information is stored for use in future transactions.

    0 讨论(0)
  • 2020-12-04 20:24

    Because web services are based on HTTP, which is a stateless protocol.

    Quoting wikipedia :

    A stateless server is a server that treats each request as an independent transaction that is unrelated to any previous request.

    i.e. each request is independant from the previous one : even if we use some "tricks", like cookies for instance, to preserve some state between requests, this is not something defined by the protocol.

    0 讨论(0)
提交回复
热议问题