Question on object instace & web service

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,
I have a (stupid) question on why web service class needs an instance.
Everybody knows its stateless then why cant it can be standardized that all
methos in web service class should be static. For eg I create an instance
websrv.
I have 2(set/get) methods and a private variable 'name'.
websrv.setName("Hello"); and in next line if I call
websrv.getName() obviously it wont work. then why cant we make it static.
 
Ravi said:
I have a (stupid) question on why web service class needs an instance.
Everybody knows its stateless then why cant it can be standardized that all
methos in web service class should be static. For eg I create an instance
websrv.
I have 2(set/get) methods and a private variable 'name'.
websrv.setName("Hello"); and in next line if I call
websrv.getName() obviously it wont work. then why cant we make it static.

Actually, I think it *might* work, depending on how the web service
deals with sessions.

More importantly though, the methods can't be static because of the
various instance properties to do with the web service class which are
needed to know what server to contact etc - things like the url, the
proxy etc.
 
Ravi said:
Hi,
I have a (stupid) question on why web service class needs an
instance.
Everybody knows its stateless then why cant it can be standardized that
all methos in web service class should be static. For eg I create an
instance websrv.
I have 2(set/get) methods and a private variable 'name'.
websrv.setName("Hello"); and in next line if I call
websrv.getName() obviously it wont work. then why cant we make it static.

You should use remoting.
 
Ravi,

In addition what Jon wrote.

I am not sure about a webservice, however I would not know why it would
works different.

In any webapplication does the serverside application belongs to all active
clients.

For me it is a multitier especially if you use static/shared classes.

The application running in the Client inside IE is the client (it is a real
application running in IE, even if you don't think in it in that way)

The Dll on the serversides gives requested data (even if it is the first
time nothing) to the clients and processes returned data.

The database (whatever it is) holds the data.

When there are no more sessions active, than the program ends and you have
to initialize everything new.

I hope this gives an idea

Cor
 
Thanks for that. Yes what you said makes sense if its happening in web
applications then web service is no different.
 
Back
Top