[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

What do WebMethod Attribute do exactly in Dot.Net

Posted on 2007-11-13
4
Medium Priority
?
1,066 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 2000 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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Integration Management Part 2
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses
Course of the Month19 days, 21 hours left to enroll

873 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