Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

WebService variables

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hi,

please take a look at this scenario :

in a webservice :

public static int A=0;
public int B=0;

in mySet webmethod : A = 2; B = 2;

in myGetA webmethod : return A;
in myGetB webmethod : return B;

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

Client1 : service.mySet();
Client2 : service.myGetA(); ---> what will return? 0 or 2
Client3 : service.myGetB(); ---> what will return? 0 or 2


Is this member variables shared between all Clients that have an instance of webservice and use with proxy?!

Regards,
Amin.
 
I haven't used webservices, but my understanding is that they're stateless. So in the first call you set the values for A & B, but then they go out of scope and B gets destroyed (garbage collected). A remains because it is declared as static (shared among all instances of your class). When the client then calls the myGetA they get 2. When they call myGetB, the value of B is undefined.

Chip H.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top