web service life cycle

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.
 
S

Softwaremaker

Hi,

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.

There is an article found at the link below that explains the concept of the
"Cache Keys" here
http://www.dotnetjunkies.com/Article/81DF138A-E188-413A-A63A-5BF96CBD6E1A.dcik

hth.

--
Thank you very much

Warmest Regards,
William T (Willie) - Softwaremaker
Architect | Evangelist | Consultant

Microsoft Regional Director
http://www.microsoft.com/rd

+++++++++++++++++++++++++++++++++
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top