You can refine a web service, by using features provided by the WebMethod attribute. You can use the WebMethod attribute to the methods you want to expose as a part of a web service and you can use the Description property to attach a description. The next table lists several additional WebMethod attribute properties, you can use to refine a web service:

 

Property

Description

Description

The method’s description.

MessageName

The alias name for the method, which is used if you have overloaded versions of the method or if you want to expose the method with a different name. This technique is deprecated.

CacheDuration

This is the number of seconds that the method’s response will be maintained in cache. The default is zero, meaning it’s not cached.

EnableSession

Gets or sets whether the method can access information in the Session collection.

BufferResponse

Gets or sets whether the method’s response is buffered. It is true by default, and it should be set to false only if you know that the request will take long to complete and you want to send sections of data earlier.

TransactionOption

Gets or sets whether the method supports transaction and of what type. Allowed values are disabled, NotSupported, Supported, Required, and RequiresNew. Because of the stateless nature of web services, they can participate only as the root object of a transaction.