Windows DNA lets you serve up components and transactions
At the Microsoft Professional Developers Conference '97 in California last September, Microsoft introduced the Windows Distributed interNet Application Architecture (Windows DNA), a framework for building multitier distributed computing solutions. Since then, Windows DNA has received both positive and negative press, with most of the negative press resulting from confusion surrounding the term Windows DNA and its components. To help clear up this confusion, I will introduce two major pieces of DNA, Distributed Component Object Model (DCOM) and Microsoft Transaction Server (MTS), and describe how they interact with a third major part of DNA, Internet Information Server (IIS) 4.0.
Developing DNA Applications with COM
Windows DNA lets you develop client/server applications, intranet applications, Internet applications, and a mixture of all three types. The application can use most Microsoft products with third-party components and tools. Windows NT Server and a database, such as SQL Server or Oracle, usually serve as the foundation for such an application. A Windows DNA application typically uses middle-tier business rule components and other front-end and back-end components built using the Component Object Model (COM).
COM is the most popular architecture for implementing components in a Windows environment. A COM component is simply an application or piece of code, such as an ActiveX component or control, that exposes parts of itself for other applications to use through COM's standard interface mechanisms. For example, a developer might create a customer component and expose particular attributes (known as properties) of the customer, such as name, address, and telephone number. Other applications can then use the customer component and either read or set the exposed properties. In addition to exposing properties, a COM component can also expose methods (known as actions) that other applications can use. For example, the customer component might have both Add and Delete actions, where Add creates a new customer and Delete removes an existing customer.
You can create COM components with Visual Basic (VB), C++, Delphi, Visual J++, and other languages. Because COM is a binary standard, it is language independent. Therefore, you can interchange COM components among any applications or development tools that adhere to the COM specification.
COM components are extremely powerful. Many vendors, such as Microsoft, build major business applications, such as Microsoft Office 97, using many different components that other applications can use via COM. Almost everything Microsoft ships exposes a COM interface for the application. Your organization might be creating COM components to encapsulate various layers of its business rules. Such components are usually known as business objects. For example, most companies that sell products or services have pricing rules. You can use COM to encapsulate the pricing rules into a component for other applications to use. This sharing makes changing the pricing rules easy, because all you have to do is change that one component to make all the applications use the latest pricing rules. Another example is shop floor components for the factory floor. You can easily build a set of COM components that package functions such as shop floor inventory handling, employee tool issuing, and time card entry.
DCOM even lets applications use remote procedure calls (RPCs) and a network transport (such as TCP/IP) to remotely access COM components. DCOM hides all the details from the developer, so anyone with the proper security credentials can run the DCOM Configuration tool (dcomcnfg.exe), which comes with DCOM, and configure a component to execute remotely.
Serving Up COM Components
Now that you understand a little about COM components, you can begin to understand how they relate to IIS and specifically to Active Server Pages (ASP) applications. ASP applications can execute a COM component by just adding a line or two of program code to the page. For example, you can add a few lines of code to use a Calculator component. The following line creates an instance of this component:
Set obj = Server.CreateObject("Math.Calc")
Two more lines of code set the properties of the Math.Calc component I just created:
Obj.Op1 = 2
Obj.Op2 = 5
Next, I execute the Add method:
Obj.Add
Finally, I can retrieve the result and send it to the HTML stream:
Response.Write "Result is: " & Obj.Result
This code segment shows why COM components are so powerful. I simply use the component as a black box that performs some function.
Now, each time the ASP page executes, the Math.Calc component executes and carries out any instructions I program in the code. This functionality is great because components let developers reuse code and achieve large efficiencies in development projects.
The ASP files that make up an IIS application contain script code (usually either VBScript or JScript) and HTML. Each ASP file requires resources (at least CPU and memory) on your server. In addition to these resources, IIS caches the ASP files in memory to improve performance.
With IIS 3.0, all ASP pages and other in-process components run in the same memory space as the IIS Web service. ASP pages are relatively bulletproof, and the script in a page can create an instance of a COM component and use it like any other application, as my previous calculator example shows. An in-process COM component, such as an ActiveX component, will run in the same memory space as the Web service. Unfortunately, if the ActiveX component crashes, it can also crash the Web service. Despite this risk, many developers use in-process components because they are much faster and consume fewer resources than out-of-process components.
With IIS 4.0, you can create ASP applications that run in their own memory space, so that if the application crashes, it won't crash the server. This IIS 4.0 feature is a major improvement over IIS 3.0. You can set the ASP application to run in its own memory space using the IIS snap-in in the Microsoft Management Console (MMC) and checking the box Run in separate memory space (isolated process), as you see in Screen 1. Even if you have a Webmaster who handles such Web-related tasks, you need to understand the ramifications of such settings.