Specifies whether this method is a web method. Applies only in a class that is defined as a web service or web client.
This keyword specifies that this method is available as a web method and can be invoked via the SOAP protocol.
In most cases, web methods should be instance methods, rather than class methods. For details and for other requirements for a web method, see Creating Web Services and Web Clients.
If you omit this keyword, the method is not available as a web method.
When you add this keyword to a method and compile the class, the class compiler generates an additional class: Package.OriginalClass.MethodName, where Package.OriginalClass is the class that contains the web method, and MethodName is the name of web method.
For example, suppose that you start with the class ROBJDemo.DocLiteralWS and you add a method to it named Add. When you add the WebMethod keyword to that method and compile, the class compiler generates the class ROBJDemo.DocLiteralWS.Add.
Do not modify or directly use this generated class; it is intended only for internal use.
Relationship to WSDL
For a web service, this keyword also affects the generated WSDL, which now contains the additional elements needed to represent this web method.