Chapter 15: ASP.NET Web Services

ASP.NET offers the programmer two basic web application project types: web forms and web services. Web forms are designed to provide presentation logic while consuming business logic or data logic. Web services are designed to provide business logic across the Internet and consume data logic. A web services project does not offer the programmer any presentation logic controls. Most web services are designed to be consumed by another web service, by software hosted on an alternative platform, or by a web form prior to an end user receiving any data processed by the web service.

Web Services Architecture

An ASP.NET web service consists of a dynamic link library (DLL), an ASMX file, and the Codebehind file, which contains a class specifically designed to support the needs of the web service. The ASMX file is analogous to the ASP.NET web form ASPX file. Requests to a web service occur via an ASMX file. You can think of the web service as a class with an integrated HTTP interface. For this reason, the web service and the web service’s class are essentially the same entity, and as such will be referred to in a collective manner in this chapter. Other classes may be added to the project, but they do not require creation of another ASMX file, since they are not web services themselves. When another class is added, only one file is created to host the code for the class, and it is named <class name>.cs or <class name>.<language extension>.

A web service project in Visual Studio .NET can contain many web services. When a web service project is compiled, the resulting assembly will be written into a single DLL. Many ASMX files could have their class hosted in the same DLL. The DLL can contain many classes in addition to the classes used to support a web service ASMX file.

The ASMX file is mapped to the .NET Framework aspnet_isapi.dll Internet Server Application Programming Interface (ISAPI) extension in IIS, so when a respective ASMX file is requested from IIS, aspnet_isapi.dll marshals the Hypertext Transfer Protocol (HTTP) request to the related web service DLL, as shown in Figure 15-1. An ASMX file is associated with a single DLL at any given time. Typically, the web services projects in Visual Studio .NET place the DLL in a bin directory subordinate to the directory hosting the ASMX files.

click to expand
Figure 15-1: Overview of the web services architecture

An ASP.NET web service project uses the same assembly configuration files used by an ASP.NET web form project. The ASP.NET web service also has the same IIS deployment configuration files as the ASP.NET web form project. The ASP.NET web service files that are used by the compiler to make a web service in the assembly are named <my web Service Name>.asmx, as contrasted to the ASP.NET web form files, which are named using the .aspx extension. The ASP.NET web service also follows the same architecture, as far as the types of files that relate to a given web service within a project. For example, the ASMX file is the addressable entry point to the web service, and like a header file, it provides processing directives for the web service compilation. The ASMX file describes the files that contribute to the ASP.NET web service, and it can host the code itself. It’s likely that the associated code for the ASP.NET web service is hosted in a Codebehind file. The <myservice>.asmx.cs Codebehind file contains the source code to the web service, and the <myservice>.asmx.resx file is the resource file that serves the Codebehind file.

Note 

The ASMX file could also host the code instead of using a Codebehind file for this, but Visual Studio .NET uses the Codebehind file in the web service project template by default. If the ASMX file does not use a Codebehind file, the .NET Framework will compile the file and produce the DLL automatically on the first request.




IIS 6(c) The Complete Reference
IIS 6: The Complete Reference
ISBN: 0072224959
EAN: 2147483647
Year: 2005
Pages: 193

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