C
Chris Dunaway
I have a simple web service defined with a few WebMethods (I'm using
VB.Net). I presume that a web service is supposed to be a stateless model,
but I have need to keep track of some information and wanted to find out
about how shared objects are treated by the web service.
Here is the scenario:
A client application calls the WebService's Login Web method. The Login
method returns a "session key" back to the client. For each subsequent
request made to the web service, the client passes in that same key. The
web method verifies that the key is valid, and if so, carries out the web
method.
A requirement I have is that for a particular user, they can only access
the web service from a single location at a time. If they log in at a
different location, they will get a NEW session key and the old one will be
invalid.
I added an arraylist and declared it Private Shared in the web service.
Further, the New method of the web service instanciates the arraylist.
When the user "logs on", the session key is created and then stored in this
arraylist. When another web method is called, it will check this arraylist
for the key and if found will continue on with its work, otherwise a
failure code will be returned and the user will be told that the session is
no longer valid and they will need to "log on" again. The session keys
will expire a certain period of time after they are created. I've got that
part working (its a little more involved, but those are the basics).
My question is about this shared array list. What is its lifetime? Does
it exist only until the next time the web service is accessed? When will
it be cleaned up? Do I need to clean it up manually?
Thanks for any help.
VB.Net). I presume that a web service is supposed to be a stateless model,
but I have need to keep track of some information and wanted to find out
about how shared objects are treated by the web service.
Here is the scenario:
A client application calls the WebService's Login Web method. The Login
method returns a "session key" back to the client. For each subsequent
request made to the web service, the client passes in that same key. The
web method verifies that the key is valid, and if so, carries out the web
method.
A requirement I have is that for a particular user, they can only access
the web service from a single location at a time. If they log in at a
different location, they will get a NEW session key and the old one will be
invalid.
I added an arraylist and declared it Private Shared in the web service.
Further, the New method of the web service instanciates the arraylist.
When the user "logs on", the session key is created and then stored in this
arraylist. When another web method is called, it will check this arraylist
for the key and if found will continue on with its work, otherwise a
failure code will be returned and the user will be told that the session is
no longer valid and they will need to "log on" again. The session keys
will expire a certain period of time after they are created. I've got that
part working (its a little more involved, but those are the basics).
My question is about this shared array list. What is its lifetime? Does
it exist only until the next time the web service is accessed? When will
it be cleaned up? Do I need to clean it up manually?
Thanks for any help.