Metro
Metro

Reputation: 1171

web service statefulness

I have two wcf services with the same interface hosted in IIS using http binding. Both have only three methods:

  1. OpenFile(userid) which creates or opens userid.txt.

  2. Write(userid, X) which writes X into the file

  3. Close(userid) which closes the file

InstanceContextMode =InstanceContextMode.PerSession is used for Service B.

Service A:

Service B:

I guess a more general question is whether the statefulness of the web service depends on how it's designed and implemented or how it is hosted? Is there like a "checklist" that I can go through to determine if my web service is categorize as stateless or stateful?

Thanks

Upvotes: 1

Views: 1105

Answers (1)

Abel
Abel

Reputation: 57169

By default, anything over HTTP is stateless. When you use PerSession, it still depends on whether your web service implementations use Sessions. But whatever the case, your web server remains stateless, which is precisely while you retain state in a special object (Cache, File, Database or Session).

Even a Session is stateless: unless the server sends the cookie in the HTTP request, nothing is remembered between requests.

This doesn't change for HTTPS. While it is a completely different protocol, the statefulness doesn't change.

About your checklist: it will be short, as it is always stateless with HTTP. Whether or not an implementation maintains state doesn't change this. It's up to the implementation how to work around this limitation and to maintain state, you cannot "see" that on the outside.

Upvotes: 2

Related Questions