Microsoft Windows NT and Windows 2000 (W2K) come with Internet Information Server (IIS) as a free service built into the operating system. What you might not know is that you can use an NT or W2K server to publish your AS/400 data cheaply and effectively on the Internet or on your company?s intranet. This article will discuss the technologies available for accessing your AS/400 data using IIS and give some example code so that you can see how simple it is to deploy.
What Is IIS?
The first thing you need to understand is that IIS is built into Windows NT 4.0 and W2K. IIS is tightly integrated with the Windows operating system and operates as a Windows service. The following are some of the neat functions available in IIS:
? Ability to run Active Server Pages (ASP) and JavaServer Pages (JSP) applications
? Ability to access Windows Component Object Model (COM)/ ActiveX Data Object (ADO)
? Integration with Windows security
Some of you may think IIS is not robust enough to serve as a deployment platform for your AS/400 data, but on this point I beg to differ. Let me explain why. Currently, Microsoft has the third-largest and most-visited site on the Internet. The site contains 59 GB of content, serves 5 million visitors a day, and is updated by over 1,000 employees around the world. They update or change from 3 to 7 percent of the content daily, and in December, the Microsoft site had over two billion page views (yes, billion with a ?b?). The interesting thing about this is Microsoft?s site runs on W2K and uses IIS 5.0, which is a pretty good reason for using this technology.
Another positive aspect of using IIS is that it is cheap. You can buy a Pentium III computer with 512 MB of RAM for about $2000 and then add in some cheap PC DASD. At the time of this writing, you can purchase 27 GB drives for around $225. Add a copy of
NT Server 5 user edition for $750 (you only need the base copy, because IIS concurrent Internet connections do not fit into the licensing scheme), and you are ready to serve your users with a high-performance Web server. In fact, you could run IIS from NT workstation, but the server edition gives you a few more operating system features that you may want for future expansion. So, for about $2,700, you have a complete server ready to handle hundreds of simultaneous user requests, whether dynamic requests (ASP and ISAPI requests) or static HTML.
If you grow beyond this hardware, a free download from Microsoft will allow you to do TCP/IP load balancing. This software, Windows NT Load Balancing Service (WLBS), allows you to run multiple NT servers to serve the same content. If a server fails, it will automatically shift the user to another server. You can run up to 32 servers per cluster, and the WLBS software will automatically configure itself based on additions or changes to the states of computers attached to the cluster. You run the software on each computer that is to be part of the cluster, and the best part is there is no need to modify your content to take advantage of clustered server operations.
My last point is price performance. Check out PC Magazine?s review of IIS at www.zdnet.com/pcmag/features/Webserver98/rev4.html to get the skinny. The main thing is that ZDNet found the IIS server to be the fastest HTML server on the market. So let?s review: It?s free with an NT license, it runs on cheap hardware, it supports load balancing, and it performs very well. Enough said. Let?s look at how to make it do something!
The Tools of the Trade
IIS runs as an NT service, so it can be monitored via the control panel. To configure IIS, you use the Microsoft Management Console (MMC). MMC started shipping with NT option pack 2 and is Microsoft?s strategy for making a universal console for management of Windows services and applications. Vendors write plug-ins that run under the MMC interface, sort of like Operations Navigator. The IIS plugin for MMC gives you graphical access for administering the server and each Web site that the server is serving. You can control site security, FrontPage extensions, indexing, and other properties from this interface.
One of the best features of IIS is its ability to run ASP applications. An ASP is like a normal HTML page, but it has script code embedded into the page. When the server gets a request for the ASP page, the server reads and processes all of the embedded script before sending the page to the client.
ASP scripts can be written in VBScript or JScript. With a third-party product, they can also be written in Perl or REXX. My favorite scripting language is VBScript because it is based on the BASIC language. Anyone can program in VBScript. Heck, it?s BASIC. If you have ever programmed a Word or Excel macro, you?ve used VBScript. Also, Windows 98 and W2K include Windows Scripting Host built into the operating system, so you can write script programs that control or administer operating system services like Active Directory Services and Domain Name System (DNS), or even communicate with the AS/400 from a browser.
ASP scripts, whatever language they?re written in, can access any ActiveX/COM object installed on the NT machine. This capability makes them extremely powerful. They allow you to leverage other people?s objects and code when you are trying to create your site. As an example, I just finished building a site that uses Crystal Reports from ASP pages to generate ad hoc reports and display them in the client browser. The beauty of COM is that I could do this easily by using the Crystal Reports COM properties and methods. For more information on controlling Crystal from ASP pages, see ?Piecing Together the Web-distribution Puzzle,? MC, February 2000.
Other types of COM objects you might want to use to create dynamic content include the Microsoft Word, Excel, Visio, and PowerPoint programs, and even the Microsoft Graph program to create interactive charts. Almost all Windows programs
expose their internal methods and properties through COM, so this gives you a leg up in leveraging existing programs and methodologies in creating your site.
Another component of NT that can be accessed through COM is the CDONTS (Collaboration Data Object for NT Server) object model. This object allows you to send or access mail and public folders on a Microsoft Exchange Server. I have used CDO as part of my ASP scripts under IIS to perform functions like sending reports to users and enabling custom discussion groups within an intranet server. And it?s so easy. Look at the code in Figure 1. This is all the ASP code required to send an Adobe PDF document as a mail attachment to a user?s email account using IIS. There are other features built into IIS and ASP, and I suggest you visit Microsoft?s Windows NT Server Web Services home page (www.microsoft.com/ntserver/Web/ default.asp) for more information about using IIS and ASP features.
Getting to DB2/400 and Notes Data
The most common use of ASP pages is publishing data contained in databases. The preferred method of getting to the data is ADO (ActiveX Data Object). ADO is an easy-touse programming interface that is positioned on top of OLE DB. ADO allows you to access any data source that has an ODBC or OLE DB provider. Because all commercial databases have ODBC drivers available for the Windows platform, this is my preferred method of communicating with databases.
To communicate with DB2/400, I use either IBM?s AS/400 Client Access Express for Windows ODBC provider or HiT Software?s ODBC provider. Both are mature providers, and they support the free-threaded model of execution. This threading model has the best performance when the site is executing many data-requesting ASP pages at once. If a driver is not free-threaded, NT places the requests in a queue and executes them one at a time. This can be bad for your site?s performance when you get under a heavy load, so you want to avoid drivers that are not free-threaded. Also note that the driver must be able to run as an NT service without interacting with the Windows desktop, because this is how ASP applications execute.
Another data access feature of IIS is connection pooling. Connection pooling allows IIS to keep ODBC connections alive, even after the script has completed execution, so that the connection can be reused by another script. Connection pooling really makes a data-driven site hum. You can enable connection pooling for an ODBC driver by going to the ODBC control panel applet, selecting the Connection Pooling tab, and double-clicking the driver you want to pool. You are allowed to turn pooling on and adjust the time that the connection will be maintained. My site is very active, so I keep my connections alive for 60 seconds. You may need to work with this value to find the optimal settings.
Making It Work
OK. Enough background information on IIS and ASP. Now we are going to make it do something useful. All AS/400 systems have a library called QSYS2, which contains a file called SYSTABLES. The SYSTABLES file contains an entry for each table and view on your AS/400 system. Figure 2 shows a simple ASP page that will display a list of libraries on your AS/400 system by using IIS. The ASP script itself is very simple; the subtlety is in what it can do. When a client browser requests the script from an ASP-enabled Web server, the server reads the script and performs the following actions specified in the script:
? Create an ADO recordset object
? Log the recordset into an ODBC data source called NAS400
? Execute the SQL command to read a list of libraries
? Format a hyperlink showing the library name for each library returned
? Close the recordset
Voila! There are 28 lines of script, and you displayed a list of your AS/400 libraries in someone?s browser. This script and it?s companion TableList.ASP are available for download from the MC Web site. You could expand them to provide even more functionality, such as displaying columns and relational information about your DB2 database.
Put It to the Test
ASP is a reliable way to easily build and deploy Web applications. By using COM, you can leverage existing Windows programs and functions to help you create that next killer Web- enabled app. Using ADO allows for high-speed access to existing data on your AS/400. IIS is obviously a robust and feature-rich Web server that is able to run some of the most active sites in the world. I think this technology deserves a test drive.
Reference and Related Materials
? ?Microsoft Corp.: Microsoft Internet Information Server,? Greg Alwang, PC Magazine Online, May 5, 1998, www.zdnet.com/ pcmag/features/Webserver98/rev4.html
? Microsoft?s Windows NT Server Web Services home page: www.microsoft. com/ntserver/Web/default.asp
? ?Piecing Together the Web-distribution Puzzle,? Michael Cape, MC, February 2000
Figure 1: Use this code to send PDF documents
Figure 2: This ASP script will return a list of your AS/400 libraries