Expose class properties in a web service

  • Thread starter Thread starter erik
  • Start date Start date
E

erik

Hi!
Is it possible to expose customer properties used in a class in a web
servies. Can I use [WebMethod] on a property or how do I do? The thing
is that I do not want to use parameters for the method I have developed
but instead use properties.
/erik
 
Erik,

Web Methods are just that, methods. You can not expose properties. In
a sense, properties are indicative of state, which generally, Web Methods
(because of the underlying transport, HTTP, which is stateless) do not have,
unless it is implemented by the web method itself.

Needless to say, you would need to implement two methods, one to get a
value, and one to set a value.

Another reason why properties are bad ideas for web methods is that they
are not very "chunky" calls. When making calls across a network (like with
web methods), you want to try and consolidate the amount of information you
send over.

If you have to set five properties and then call a method to get a
result, it is more consuming to do that, than to pass all five values to the
method just one time.

Hope this helps.
 

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

Back
Top