web service life cycle

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.

--
Chris

To send me an E-mail, remove the underscores and lunchmeat from my E-Mail
address.

Advertisements

Web Services are Stateless and thus doenst have a lifeline of shared
objects, per se

I had done something like what you had described below, however I store the
"keys" in a database and I cache the output so that the
Web Service can retrieve it efficiently. I did that as well to "keep track"
and have some kind of an audit log as well.

"Chris Dunaway" <dunawayc@_lunchmeat_sbcglobal.net> wrote in message
news:...
> 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.
>
> --
> Chris
>
> To send me an E-mail, remove the underscores and lunchmeat from my E-Mail
> address.

Share This Page

Welcome to The Coding Forums!

Welcome to the Coding Forums, the place to chat about anything related to programming and coding languages.

Please join our friendly community by clicking the button below - it only takes a few seconds and is totally free. You'll be able to ask questions about coding or chat with the community and help others.
Sign up now!