Solved

What do WebMethod Attribute do exactly in Dot.Net

Posted on 2007-11-13
4
1,053 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
Comment Utility
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
Comment Utility
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
Comment Utility
In other words [WebMethod] prefix marks the function as the one being exposed by the web service
0
 
LVL 18

Expert Comment

by:mdougan
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

763 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

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now