Why are properties not available in WebService?

P

Paul Liebrand

Can someone tell me (or point me to documentation) that explains why Properties are not available in WebService?
 
M

Michael Pearson

It's probably due to the statelessness of the Web.

One solution might be to create a class with all the properties you want on
the client side, and just pass that whole class into the webservice. It
could then get whatever state data it needs from that class and do it's
thing. I think I'd just suggest passing all of yoru arguments into each
method though.

Michael

Paul Liebrand said:
Can someone tell me (or point me to documentation) that explains why
Properties are not available in WebService?
 
S

Sami Vaaraniemi

Paul Liebrand said:
Can someone tell me (or point me to documentation) that explains why
Properties are not available in WebService?

Are you asking why a WebService cannot expose properties the same way it can
expose WebMethods?

Well, I guess in theory the .NET Web services implementation could support
properties. All it would require is a mapping from the SOAP message on a
suitable property in the web service proxy class and in the web service
implementation.

However, properties make little sense with Web services because they imply
an object-oriented model, and Web services are not distributed objects.
There are a couple of issues.

First, having properties would encourage the design of chatty interfaces:

double x = webService.X;
double y = webService.Y;
double z = webService.Z;

With this you would get three roundtrips to the server. Instead of chatty,
you want to do chunky interfaces:

double[3] xyz = webService.getXYZ();

Another reason is that properties imply a stateful model:

webService.Foo = "Foo";
string foo = webService.Foo;
Diagnostics.Assert(foo == "Foo");

Again, this is not exactly what Web services are designed to do. Web
services typically maintain no state.

Sami
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,021
Latest member
AkilahJaim

Latest Threads

Top