Working with Web Services Using ASP.NET
page 5 of 11
by SANJIT SIL
Feedback
Average Rating: 
Views (Total / Last 10 Days): 59300/ 89

The Web Method Attribute

A Web Service class can contain any number of WebMethods that are accessible across the HTTP wire.  Like the Web Service attribute, WebMethod can also contain some properties which are described in this section.

CacheDuration

CacheDuration specifies the number of seconds that the response should be held in the system’s cache.  By default, the caching is disabled.  Putting an XML Web Service’s response in the cache increases the Web service’s performance.  We can write the same as specified in Listing 3

Listing 3

[WebMethod(CacheDuration=30)]

BufferResponse

Buffering allows the server to buffer the output from the response of XML Web Service and transmit it only once the response is completely buffered.  By default, this property is set to true. If we make the property to false, the response is sent to the client as it is constructed on the server.

Description

The description property is used to provide a brief description to the WebMethod and the description becomes part of the service description (WSDL) document.

EnableSession

EnableSession property enables session state for a particular WebMethod if we set the property to true. The default setting is false.

MessageName

MessageName property is required to uniquely identify polymorphic methods within a class.  In case of working with overloaded WebMethods this property is a required one.

TransactionOption

By default, transactions are disabled.  If we decide to use .NET transactions, our WebMethod will be able to participate only as the root object in a transaction.  This means that our WebMethod may call other transaction-enabled objects, but may not itself be called as part of a transaction started by another object.  This limitation is due to the stateless nature of the HTTP protocol.  As a result, the Required and RequiresNew values for TransactionOption are equivalent (and both declare a RequiresNew method that will start a new transaction).  Disabled, NotSupported, and Supported are all disable transactions for the web method despite what their names imply.


View Entire Article

User Comments

No comments posted yet.

Product Spotlight
Product Spotlight 





Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2024 ASPAlliance.com  |  Page Processed at 2024-04-25 7:25:02 PM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search