What do WebMethod Attribute do exactly in Dot.Net

I read some articles about basics of Attributes in net. But I do not get a pretty good understanding of how to use them instead of putting some information into assebly. There are some attributes I see like when creating a web service. [WebMethod]
What does it do?
karanbaAsked:
Who is Participating?
 
mdouganConnect With a Mentor Commented:
Webmethod tells the compiler to make this method visible when people query the WSDL to see what methods are available to call in your Webservice.

So, any method that you want someone to be able to call in your webservice needs to have this attribute.  If some method inside your webservice needs to call another method inside the webservice, then that method doesn't need the attribute, because it doesn't have to be visible to the outside world.
0
 
YZlatCommented:
when web service is called, it calls only one method out of all methods for that particular web service. [WebMethod] prefix defines which one of the methods will be the default method for that web service
0
 
YZlatCommented:
In other words [WebMethod] prefix marks the function as the one being exposed by the web service
0
 
mdouganCommented:
You can define more than one Webmethod in a webservice.  Any method that you'd like to be able to call from outside the webservice, can be declared with Webmethod.  If you define more than one, I'm not sure which would be considered the "default" though.
0
All Courses

From novice to tech pro — start learning today.