By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,966 Members | 1,520 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,966 IT Pros & Developers. It's quick & easy.

Question on object instace & web service

P: n/a
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.

Jul 21 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Ravi <Ra**@discussions.microsoft.com> wrote:
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.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jul 21 '05 #2

P: n/a
Ravi wrote:
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.

--
Texeme Textcasting Technology
http://www.texeme.com
Jul 21 '05 #3

P: n/a
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
Jul 21 '05 #4

P: n/a
Thanks for that. Yes what you said makes sense if its happening in web
applications then web service is no different.
"Cor Ligthert" wrote:
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

Jul 22 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.