test

Page 135

All right, so the algorithm is not that complex. What do you expect with an example? The important thing to note is that the implementation of the Web service is a standard public class declaration with a WebMethod attribute decorating the InstantQuote method. This class declaration can be either compiled into an assembly or placed as is within the .asmx file, and it is the same whether it is contained within the .asmx file or compiled into a separate DLL. Each method that is intended to be exposed by the Web service must be public and must be decorated with the WebMethod attribute. This tells the ASP.NET runtime to expose the method as publicly accessible. From this point on, I will refer to a method of a class decorated with the WebMethod attribute as a Web method. When you decorate a method with the WebMethod attribute, you can also set various properties that modify the behavior of the ASP.NET runtime. Table 6-1 lists the properties exposed by the WebMethod attribute. Table 6-1: Properties of the WebMethod Attribute Property

Description

BufferResponse

Specifies whether the response to the client should be buffered.

CacheDuration

Specifies the amount of time, in seconds, that a response will be cached in memory by the Web server for a given response. The default is 0.

Description

Specifies the value of the description element under each operation element within each type definition within the ASP.NETgenerated WSDL document.

EnableSession

Specifies whether the ASP.NET session state services will be available for the implementation of the method.

MessageName

Specifies the name of the method exposed by the Web service. Specifically, it sets the name of the element within the body of the SOAP message that contains the parameters as well as the suffix of the SOAP action. It also specifies the prefix of the names of the message, input, and output elements within the ASP.NET-generated WSDL document.

TransactionOption

Specifies the transactional support that should be provided for the implementation of the method. The method can serve only as the root of a transaction and cannot participate in the caller’s transaction.

The ASP.NET page framework also provides the WebService attribute. This attribute is set at the class level and is used to modify properties of the Web service as a whole. Changes made via the WebService attribute will be reflected in the Web service’s WSDL document. Table 6-2 lists the properties exposed by the WebService attribute. Table 6-2: Properties of the WebService Attribute Property

Description

Description

Specifies the description element under the service element within the ASP.NET-generated WSDL document.

135


Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.