Request specific singleton in webservice ?

  • Thread starter Poul Lund J?rgensen
  • Start date
P

Poul Lund J?rgensen

Hi,

I would like to use the singleton pattern in a webservice in order to
ensure one and only one instance of certains objects within the
context of the webservice request.

When I try to build the usual singleton pattern with the static
instance variable I notice that the static member is shared between
different webservice call which is NOT what I want.

I am considering using the HttpContext.Current.Items dictonary as a
kind of webservice local singleton storage in order to avoid the
singletons being shared between webservice call, but it would require
a lot refactoring in the current application.

Does anyone know a better way to obtain webservice locale singletons ?

best regards
Poul Lund Jørgensen
 
C

Charlie Nilsson [MSFT]

You'll have to use static variables or maintain an index / collection
that's shared in your web service call. Start by thinking what objects
are created and then destroyed by the SOAP / web service calls, independent
of other calls.

Maybe you would want to store this variable in the WebService.Context
object (of type System.Web.HttpContext) which is created for the request.
Check out the "Items" collection member variable.

--
CharlieN
DevDiv

This posting is provided "AS IS" with no warranties, and confers no rights.

Note: For the benefit of the community-at-large, all responses to this
message are best directed to the newsgroup/thread from which they
originated.

--------------------
 

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,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top