Section 15.4. WebService Directive


15.4. WebService Directive

You can see the first difference between a web service and a web page in the web service file listed in Example 15-2. A normal .aspx file will have a Page directive as its first line, but a web service has a WebService directive as reproduced here:

 <%@ WebService Language="C#" CodeBehind="~/App_Code/Service.cs"         Class="Service" %> 

The WebService directive is required of all web services. Like all directives, it has the following syntax:

 <%@ DirectiveName attribute="value" [attribute="value"...]%> 

You can have multiple attribute/value pairs. The order of the attribute/value pairs does not matter.



Language

The WebService directive's Language attribute specifies the language used in the web service. Legal values include C# , VB , and JS for C#, VB2005, and Jscript.NET, respectively. The value is not case-sensitive. The Language attribute is not required. If it is missing, the compiler will deduce the language in use from the extension of the class file.



Class

The WebService directive's Class attribute specifies the name of the class implementing the web service. The Class attribute is required. The class specified can reside either in a separate code-behind file, or in-line in a script block in the .asmx file.

If the web service is developed in VS2005, the code-behind file containing the class will be located in a subdirectory under the application root (where the .asmx file resides) called App_Cod e. Any code files in a subdirectory with this name will automatically be compiled by the .NET Framework when the application is run.

If the web service is developed outside of VS2005, or with a previous version of Visual Studio, then the class file must be compiled and the resulting dll placed in the bin subdirectory under the application root directory. Manual compilation is covered later in this chapter and in Chapter 19.



CodeBehind

The WebService directive's CodeBehind attribute will specify the name of the source code file that implements the WebService class, if the class is not contained in-line with the web service file ( .asmx ) and if the class has not been manually compiled and placed in the bin subdirectory under the application root directory.



Debug

If true , the WebService directive's Debug attribute specifies that the web service will be compiled with debugging enabled. The default is false .

When you develop within VS2005, this attribute is typically omitted and the debug status is controlled by an entry in the web.config configuration file.



Programming ASP. NET
Programming ASP.NET 3.5
ISBN: 0596529562
EAN: 2147483647
Year: 2003
Pages: 173

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net