473,545 Members | 289 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Calling a Web Method do not change Web Service object state

I have a Web service that gets the financial periods and hold a reference to
a disconnected dataset built at initialization. Web methods work on the
dataset inside the web service. Everything is fine so far.

My problem is that when I call a web method to modify the dataset inside the
Web service it is never updated and I get no errors.

currentPeriods method will always give me 1 even if I call ChangeDataset and
call currentPeriods after.

Is this by design or I'm doing something wrong ?

Thanks.
'Simplified code here
Public Class Periods
Inherits System.Web.Serv ices.WebService
Private thePeriods As DataSet

<WebMethod> _
Public Function currentPeriods( ) As DataSet
Return thePeriods
End Function

<WebMethod> _
Public Function ChangeDataset() As boolean
'update the dataset thePeriods column1 value =2
Return true
End Function

Public Function buildDataset() As boolean
'create the dataset theDS here with column1 value =1
thePeriods=theD S
End Function

Public Sub New()
buildDataset
End Sub

End Class
Dec 20 '05 #1
5 2581
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

Dec 20 '05 #2
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
Dec 21 '05 #3
Thank you so much for your time guys. I knew it had to be something like
this, it's nice to hear it from someone else. I don't really need to share
my DS, so I will do something else. Thanks Peter and Steven, to share your
precious knowledge with all of us.

"Steven Cheng[MSFT]" wrote:
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
Xref: TK2MSFTNGXA02.p hx.gbl
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

Dec 21 '05 #4
You're welcome Joe,

Feel free to post here when you need any further help.

Good luck!

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

--------------------
Thread-Topic: Calling a Web Method do not change Web Service object state
thread-index: AcYGMqVxwsNklPG RRQa719A4tsVTXw ==
X-WBNR-Posting-Host: 204.101.63.162
From: "=?Utf-8?B?am9lYmxhc3Q =?=" <jo******@newsg roups.nospam>
References: <49************ *************** *******@microso ft.com>
<11************ **********@g47g 2000cwa.googleg roups.com>
<E1************ **@TK2MSFTNGXA0 2.phx.gbl>
Subject: Re: Calling a Web Method do not change Web Service object state
Date: Wed, 21 Dec 2005 05:30:02 -0800
Lines: 82
Message-ID: <71************ *************** *******@microso ft.com>
MIME-Version: 1.0
Content-Type: text/plain;
charset="Utf-8"
Content-Transfer-Encoding: 7bit
X-Newsreader: Microsoft CDO for Windows 2000
Content-Class: urn:content-classes:message
Importance: normal
Priority: normal
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
Newsgroups: microsoft.publi c.dotnet.framew ork.webservices
NNTP-Posting-Host: TK2MSFTNGXA03.p hx.gbl 10.40.2.250
Path: TK2MSFTNGXA02.p hx.gbl!TK2MSFTN GXA03.phx.gbl
Xref: TK2MSFTNGXA02.p hx.gbl
microsoft.publi c.dotnet.framew ork.webservices :13142
X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.webservices

Thank you so much for your time guys. I knew it had to be something like
this, it's nice to hear it from someone else. I don't really need to share
my DS, so I will do something else. Thanks Peter and Steven, to share your
precious knowledge with all of us.

"Steven Cheng[MSFT]" wrote:
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
Xref: TK2MSFTNGXA02.p hx.gbl
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


Dec 21 '05 #5
No problem Joe, good luck.

joeblast wrote:
Thank you so much for your time guys. I knew it had to be something like
this, it's nice to hear it from someone else. I don't really need to share
my DS, so I will do something else. Thanks Peter and Steven, to share your
precious knowledge with all of us.

"Steven Cheng[MSFT]" wrote:
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
Xref: TK2MSFTNGXA02.p hx.gbl
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


Dec 21 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
1387
by: Midas | last post by:
In my "main" code, I would like to create two new objects (ObjectA and ObjectB) and have ObjectA directly call an ObjectB method. In order to do this I believe ObjectA must hold a reference to ObjectB. What about the name of the method? Must it be hardcoded in ObjectA?
5
6758
by: niftyhawk | last post by:
Hi, Can anybody give me a simple example of how to Call Web Services from Mozilla based Browsers ? I can call web services from IE browser using web service behavior file, without any problems. Just wanted to know an easy way to call them from Firefox or Netscape. Thanks, Nifty.
0
2234
by: Cleo | last post by:
Hi, I am trying to call a WebService Method written in Weblogic from VB.NET and I am getting the following error. I am using SOAP Caal s from VB.NET. Please find the wsdl file and my code. Any help would really be appreciated. Thx
1
6719
by: Lakshmi | last post by:
Hi All, I am having performance issues with the .NET client calling the Java Webservice running on axis. Have detailed the problem below. Please help. I wrote a webservice in Java. Lets name this WebService1. (using Apache Axis 1.1) Scenario 1: -----------
2
2739
by: yqlu | last post by:
I hava developed a client in C# that is connected to a 3-party XML Web Services developed in Java based on the AXIS 1.1. Most methods call are successful except for one method named "findObjects" and return a complex type "FieldSearchResult". The error message as following : "Cannot assign object of type System.String to an object of type...
3
4061
by: Pratcp | last post by:
Hello, I have an asp.net Web app in vb.net trying to call a C# web service which takes a reference parameter. I tried a simple C# web app to call the Web service and it works perfectly. However, when I try it in the vb.net web app, I run into XML definition errors. Looks like the proxy class is not able to generate the correct XML with the...
1
4020
by: jens Jensen | last post by:
Hello , i'm calling a webservice generated with oracle webservice java tools. I'm not able to add a web reference to a .net client the usual way with visual studio 2005. I was therefore provided with a set of Dll that implement the proxy needed to consume this web service. I'm now wrapping these dlls in a .Net webservice that can be...
15
8177
by: =?Utf-8?B?VG9tIENvcmNvcmFu?= | last post by:
I've been led to believe by several articles, particularly Eric Gunnerson's C# Calling Code Dynamically, that calling a method dynamically through Reflection was much slower than through a Delegate. My testing showed that actually it was six times faster: 0.5 seconds for 100,000 iterations versus 3.1 seconds. Can anyone explain why? ...
0
7465
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7656
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7416
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7752
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5969
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5325
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4944
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3449
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
701
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.