Solved

What do WebMethod Attribute do exactly in Dot.Net

Posted on 2007-11-13
4
1,055 Views
Last Modified: 2013-11-07
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?
0
Comment
Question by:karanba
  • 2
  • 2
4 Comments
 
LVL 35

Expert Comment

by:YZlat
ID: 20275114
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
 
LVL 18

Accepted Solution

by:
mdougan earned 500 total points
ID: 20275117
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
 
LVL 35

Expert Comment

by:YZlat
ID: 20275141
In other words [WebMethod] prefix marks the function as the one being exposed by the web service
0
 
LVL 18

Expert Comment

by:mdougan
ID: 20275145
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

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question