13.07.2015 Views

Applied XML Programming for Microsoft .NET.pdf - Csbdu.in

Applied XML Programming for Microsoft .NET.pdf - Csbdu.in

Applied XML Programming for Microsoft .NET.pdf - Csbdu.in

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

effectively exposed over the Web, a Web service method requires a special attribute <strong>in</strong>addition to be<strong>in</strong>g declared as public. Only methods marked with the WebMethodattribute ga<strong>in</strong> the level of visibility sufficient to make them available over the Web.The WebMethod AttributeIn practice, the WebMethod attribute represents a member modifier similar to public,protected, or <strong>in</strong>ternal. Only public methods are affected by WebMethod, and theattribute is effective only to callers <strong>in</strong>vok<strong>in</strong>g the class over the Web. This characteristic<strong>in</strong>creases the overall flexibility of the class design. A software component allowed to<strong>in</strong>stantiate the Web service class sees all the public methods and does not necessarilyrecognize the service as a Web service. However, when the same component is<strong>in</strong>voked as part of a Web service, the IIS and ASP.<strong>NET</strong> <strong>in</strong>frastructure ensure thatexternal callers can see only methods marked with the WebMethod attribute. Anyattempt to <strong>in</strong>voke untagged methods via a URL results <strong>in</strong> a failure.The WebMethod attribute features several properties that you can use to adjust thebehavior of the method. Table 13-1 lists the properties.Table 13-1: Properties of the WebMethod AttributePropertyBufferResponseCacheDurationDescriptionEnableSessionMessageNameTransactionOptionDescriptionSet to true by default, this property <strong>in</strong>dicates that theIIS run time should buffer the method's entire responsebe<strong>for</strong>e send<strong>in</strong>g it to the client. Even if set to false, theresponse is partially buffered; however, <strong>in</strong> this case,the size of the buffer is limited to 16 KB.Specifies the number of seconds that the IIS run timeshould cache the response of the method. This<strong>in</strong><strong>for</strong>mation is useful when you can <strong>for</strong>esee that themethod will handle several calls <strong>in</strong> a short period oftime. Set to 0 by default (mean<strong>in</strong>g no cach<strong>in</strong>g), thecach<strong>in</strong>g eng<strong>in</strong>e is smart enough to recognize andcache page <strong>in</strong>vocations that use different parametervalues.Provides the description <strong>for</strong> the method. The value ofthe property is then embedded <strong>in</strong>to the WSDLdescription of the service.Set to false by default, this property makes available tothe method the Session object of the ASP.<strong>NET</strong>environment. Depend<strong>in</strong>g on how Session isconfigured, us<strong>in</strong>g this property might require cookiesupport on the client or a <strong>Microsoft</strong> SQL Server 2000<strong>in</strong>stallation on the server.Allows you to provide a publicly callable name <strong>for</strong> themethod. When you set this property, the result<strong>in</strong>gSOAP messages <strong>for</strong> the method target the name youset <strong>in</strong>stead of the actual name. Use this property togive dist<strong>in</strong>ct names to overloaded methods <strong>in</strong> theevent that you use the same class as part of themiddle tier and a Web service.Specifies the level of COM+ transactional support youwant <strong>for</strong> the method. A Web service method can haveonly two behaviors, regardless of the value assigned460

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!