Web services offer the potential for achieving seamless interoperability across disparate type platforms, programming languages, and applications. ASP.NET, discussed in Chapter 6, facilitates web-based application development. The .NET Framework infrastructure provides the basic services supporting ASP.NET as well as Windows web form development, the new rich client development technology. An attractive feature of ASP.NET is the ability to create web applications in any .NET-compliant language, whereas the older ASP technology restricted developers to programming with scripting languages. Another ASP.NET benefit is code that is compiled rather than interpreted, which considerably improves performance. Although it is preferable to write web applications within the new Visual Studio .NET IDE, you can create an ASP.NET page in Notepad, save it with an .aspx extension, and let the ASP.NET runtime compile the page dynamically when called for the first time. When coding pages in Visual Basic .NET, C#, or J# .NET, the Microsoft .NET Framework comes bundled with command-line compilers for each individual language.
ASP.NET retains many older classic version features from its previous ASP version. Request and Response remains, as well as the Application, Session, and Server objects. You can still use the familiar <SCRIPT RUNAT=”Server”> or the <% %> ASP script delimiter. ASP and ASP.NET applications can run side by side, courtesy of the Common Language Runtime, which utilizes reflection to gather assembly information from the manifest rather than registering the application in the system registry. Referencing an assembly rather than the registry has eliminated DLL hell, something all developers have experienced.
Here are several new ASP.NET features:
Server controls These controls offer convenient server-side programming. They map easily to HTML elements and can output HTML code designed especially for Internet browsers.
Web forms Drag web forms onto a page and write code to facilitate interaction with objects, such as calling them.
Web services Developers can provide services to clients and other developers. Web technology based on SOAP allows for cross-platform interoperability.
Configuration file improvements ASP.NET uses a new methodology for storing XML-based configuration information for web applications. Typically, this information is stored in an IIS database.
Caching ASP.NET has improved methods for enhancing performance by restricting database server and web server processing loads to a minimum.
State management improvement ASP.NET offers support for persisting application state information in SQL Server. This technology also enables state management without using cookies.
Security ASP.NET offers new authentication methods, improved code access security, and role-based authorization.
In order to receive full support from the .NET Framework, do the following:
Web-enabled applications should not be tightly coupled to specific platforms or programming languages.
Developers should leverage Internet-supported standards rather than creating custom solutions.
Avoid solutions displaying dependencies on any particular component.
Create web applications so they can accept any type of distributed infrastructure.
Make sure the application uses data types compatible with both the Common Type Specification and Common Language Specification.
The .NET Framework facilitates web application development in more than one programming language. Just design your application to adhere to the .NET Framework specifications. ASP.NET utilizes HTTP and Simple Object Access Protocol (SOAP). During the design phase, determine how a client and server will communicate with each other. For example, consider a scenario where both client and server reside within the same LAN. The client will most likely interact with the server via HTTP and the Internet. This means the transport protocol should function equally well within both a LAN and Internet environment. HTTP and SMTP are excellent choices for web-enabled applications.
HTTP is popular because it is intrinsically stateless and not connection oriented. If a client and server lose their connection, rerouting ensuing calls to another server carries neither risk nor loss of information. CORBA and DCOM are not good candidates for web services because the developer must write extra code to preserve state, which is not a natural function of CORBA and DCOM. You cannot simply reroute a client’s call. For this reason, HTTP is the platform-agnostic protocol of choice.
Many times, it is important to preserve application state (units of data) across a series of requests between multiple users sharing the same application. Preserving state in web applications is complex and challenging because HTTP is stateless. Fortunately, ASP.NET preserves state by providing a collection of key-value pairs that developers can apply to their web-enabled applications. The .NET HttpApplicationState class supplies state storage by representing the class as an instance of the Application property of the Page class. Every ASP.NET page inherits from this class. ASP.NET facilitates the ability to add items to the collection using the Add() method as well as clearing items from the collections by applying the Clear() method. The Application object provides the Lock and Unlock attributes to ensure that only a single user can update the application state.
Frequently, it is important to provide metadata along with messages. HTTP offers a mechanism for including specific header information along with the message body embedded within a SOAP envelope. The framework lends support for processing SOAP header files. Set them with the CallContext object. Additionally, the framework provides two APIs, called GetHeaders and SetHeaders, to set and retrieve the SOAP headers for a specific call. The GetData and SetData static methods set and retrieve data transmitted within the SOAP request message. Specify routings by defining the destination for a message or placing a time restriction for message delivery. ASP.NET supports two encoding styles, Document and Remote Procedure Calls (RPCs). By default, Document facilitates text-based messages between client and server. In contrast, RPC is the protocol of choice for machine-based exchanges. Additionally, the ASP.NET Framework offers a mechanism called SOAP extensions. This technology allows you to modify the contents of SOAP messages transmitted between client and server.
ASP.NET provides a rich set of services for building web applications, including security control. Within the ASP.NET domain, a web service contains an .asmx file, and serves as an endpoint for the web service. A class contains the web service implementation and can reside within either an .asmx file or dynamic link library (DLL). The runtime locates and consumes information contained in the .asmx file in order to locate the class. Each individual .asmx page carries directions specifying a defined format and implementation location. Subsequently, the runtime utilizes this directive to bind the web services to a particular class. The page contains an attribute that defines the fully qualified name of the class implementing the web service.
Although there is potential for creating web services and achieving interoperability across different platforms, SOAP has its problems because incompatibilities exist between releases. As an increasing number of specifications attempt to resolve incompatibilities and other issues, interoperability challenges increase. Fortunately, the SOAPBuilders community has developed interoperability test labs and discussion forums to resolve numerous problems standing in the way.