Friday, January 7, 2011

WebMethod Properties

WebMethod is an attribute that is used in Web Service to inform the CLR that particular method will expose as a part of Xml Webservice. WebMethod attribute has some properties which can be sued to control the behavior of the WebMethod.

BufferResponse :- By default it’s value is true. If it true, Response of webmethod serialized and stored in a buffer. When buffer is full or response completed than it sends the data to the client. Thus minimize communication between the worker process and IIS (Internet Information Services) process. If it is false, ASP.NET buffers the responses in chunks of 16 KB while communicating to the client.In case of large file make it false.
Ex:- Suppose we have requested 64 KB file from web service. If BufferResponse is true and Method generating 8 KB data in one go. Than Webserive will not send this 8 KB data to host but Buffer this 8 KB data until unless buffer is full or whole file is completed. And if BufferResponse is false than Webservice buffer this 8 KB data and wait for second call after the second call when data is 16 KB than it sends it to the host.

Cache Duration :- When we call a web method. Web Service cache the response of each unique set of parameter for a time span. This time span is set by Cache Duration property.By default value is zero which means no caching.

Description :- You specify what a web method will do. This will appear on the service help page.Default value is empty string.

Enable Session :- If you want to use Session in Web Service you have to set this property as true. By default value is false. You can use session in web service through HttpContext.Current.Session or with the WebService.Session property if it inherits from the WebService base class.

MessageName :- If you want to overload a WebMethod than you can use this property to uniquely identified a WebMethod. By default value is method name.

No comments:

Followers

Link