Hi Joe,
I think Peter's suggestion are reasonable. For webservice, generally we're
not recommended to include stateful data in XML webservice... However, if
you need to store such info in ASP.NET webservice so as to make it shared
to all the webmethods requests, we need to store it in a shared storage
which is application scope.... In ASP.NET, applicationStat e, application
cache or a certain class's static member variable are all the possible
approach for storing or referenceing such shared objects. Where do you
currently store the shared DataSet?
Regards,
Steven Cheng
Microsoft Online Support
Get Secure!
www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
--------------------
From: "Peter Kelcey" <Pe**********@t elus.com>
Newsgroups: microsoft.publi c.dotnet.framew ork.webservices
Subject: Re: Calling a Web Method do not change Web Service object state
Date: 20 Dec 2005 08:35:18 -0800
Organization:
http://groups.google.com
Lines: 24
Message-ID: <11************ **********@g47g 2000cwa.googleg roups.com>
References: <49************ *************** *******@microso ft.com>
NNTP-Posting-Host: 66.203.207.7
Mime-Version: 1.0
Content-Type: text/plain; charset="iso-8859-1"
X-Trace: posting.google. com 1135096523 16032 127.0.0.1 (20 Dec 2005
16:35:23 GMT)
X-Complaints-To:
gr**********@go ogle.com
NNTP-Posting-Date: Tue, 20 Dec 2005 16:35:23 +0000 (UTC)
In-Reply-To: <49************ *************** *******@microso ft.com>
User-Agent: G2/0.2
X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET
CLR 1.0.3705; .NET CLR 1.1.4322; .NET CLR 2.0.40607),gzip (gfe),gzip(gfe)
Complaints-To:
gr**********@go ogle.com
Injection-Info: g47g2000cwa.goo glegroups.com; posting-host=66.203.207 .7;
posting-account=GTafkQ0 AAAC3ac_UHAsxZ5 oy6zhk-wpe
Path:
TK2MSFTNGXA02.p hx.gbl!TK2MSFTN GP08.phx.gbl!ne wsfeed00.sul.t-online.de!t-onli
ne.de!border2.n ntp.dca.giganew s.com!border1.n ntp.dca.giganew s.com!nntp.giga n
ews.com!postnew s.google.com!g4 7g2000cwa.googl egroups.com!not-for-mail
microsoft.publi c.dotnet.framew ork.webservices :13119
X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.webservices
Joe
Webmethods represent stateless calls. I.e. Each time you call a web
service, it gets instantiates, runs the web method, returns a result
and is then destroyed (along with any class variables like your
"thePeriods "). Therefore, each time you call a webmethod, your
initialize method is called and will create the dataset again and
again. Your update method is likely performing the dataset update
correctly, but the dataset is lost when the ChangeDataset webmethod
exits. When you call your currentPeriods method, it will be working
with a brand new dataset that has no record of your changes.
What you need to do is store you dataset in a statefull object
(something like and application variable) when you initialize it. After
that, you will need to modify your initializationr outine to check the
application variable and see if it holds your dataset. If it does, then
you need to work with that instance of it instead of creating a new
instance. All of your other methods should work with this application
variable to ensure that they are all working with same dataset.
Hope that help
Peter Kelcey