web service life cycle

Discussion in 'ASP .Net Web Services' started by Chris Dunaway, Mar 4, 2004.

  1. 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.
     
    Chris Dunaway, Mar 4, 2004
    #1
    1. Advertising

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

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

    "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.
     
    Softwaremaker, Mar 4, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. john doe Jr

    ASP Life Cycle Problem

    john doe Jr, Dec 5, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    838
    Teemu Keiski
    Dec 5, 2003
  2. S. Justin Gengo

    Re: ASP Life Cycle Problem

    S. Justin Gengo, Dec 8, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    477
    S. Justin Gengo
    Dec 8, 2003
  3. prem

    ASP.Net Life Cycle

    prem, Nov 2, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    506
    Kevin Spencer
    Nov 2, 2004
  4. =?Utf-8?B?amlt?=

    Life cycle of ASP .NET Application

    =?Utf-8?B?amlt?=, Jan 18, 2005, in forum: ASP .Net
    Replies:
    6
    Views:
    7,870
    Juan T. Llibre
    Jan 19, 2005
  5. Replies:
    6
    Views:
    353
    KiLVaiDeN
    Oct 13, 2006
Loading...

Share This Page