Worked Example: How do I prototype a Web-Based
Information System?
This exercise will concentrate on using common web
technologies to implement a prototype Web-Based Information System. We shall
need the results of our initial analysis, plus a few ideas on how we might
improve the existing business process.
Just like the previous exercise 'How do I analyse and
document an existing business process using the Unified Modeling
Language', satisfactory completion of this work will provide a great deal of
assistance with the second part of your
assignment.
Before we start, we need to ensure that we have a few things
available, such as:
|
|
|
If all of this appears a little confusing or daunting, don't
worry as it will all become clear as we work through the exercise.
From the analysis so far, our selected business process uses
a variety of legacy information stores, or repositories, such as spreadsheets,
databases and paper forms and files. We are going to produce a prototype that
demonstrates how we can use current technologies to present information over
the Internet.
We will not be
producing a finished application - we are merely demonstrating the validity
of our ideas.
First of all, we should think about our approach to the
prototype. What steps are we going to take?
There is a range of technologies that we could use, and as
we need to access data from legacy systems, we are concerned with various
incompatible standards for data storage. We shall address this by using XML.
The XML is used as a common format - we only have to
consider how we can convert from different file formats to XML, rather than
creating conversions from one file format to another.
So, our conversion process looks like this:
Now that we understand what we have to do, we need some
method of automating the process. We can't expect our users to export files
from databases, convert them to XML and then represent them in a browser. Such
a procedure would be prone to errors, and time consuming.
Active Server Pages (ASP) is a scripting language that allows
us to automate tasks on the server. In this example we shall use this to automate
the generation of an XML file, using queried data from a back-end legacy database.
Making the Prototype
<%
'Dimension variables for DSN-less connection
Dim connection, query, data
Set connection = Server.CreateObject( "ADODB.Connection" )
connection.Provider="Microsoft.Jet.OLEDB.4.0"
'name database to point
to
Call connection.Open(Server.Mappath("database.mdb" ))
query = "SELECT * FROM Customers ORDER BY CustomerID"
Set rs = Server.CreateObject( "ADODB.Recordset" )
Call rs.Open( query, connection )
'Define name of output file
file_being_created= "customers.xml"
'Create a file object
set fso = createobject("scripting.filesystemobject")
Set act = fso.CreateTextFile(server.mappath(file_being_created),
true)
'Write standard xml and root
element at start of file
act.WriteLine("<?xml version=""1.0""?>")
act.WriteLine("<root>")
'Loop to output all the query results to the xml document
do while not rs.eof
'Write each element to output file
act.WriteLine("<customer>")
act.WriteLine("<custid>" & rs("CustomerID") & "</custid>"
)
act.WriteLine("<compname>" & rs("CompanyName") & "</compname>"
)
act.WriteLine("</customer>")
'Move to next record in recordset
rs.movenext
loop
'At end close root element
act.WriteLine("</root>")
act.close
%>
'Display results for query in table
<html>
<body>
<xml
src="customers.xml"
id="xmldso"
async="false">
</xml>
<table
datasrc="#xmldso"
width="100%"
border="1">
<h1>Customer Report</h1>
<thead>
<th>Customer ID</th>
<th>Company Name</th>
</thead>
<tr align="left">
<td><span datafld="custid"></span></td>
<td><span datafld="compname"></span></td>
</tr>
</table>
</body>
</html>
'Provide output to screen with hyperlink to xml file
response.write "<a href='customers.xml'>customers.xml</a> (.xml)
has been created <br>"
response.write "on " & now()
& "<br>"
Now that you have a feel for connecting to a back-end
database, experiment with the Access tables. Add some new tables, alter the SQL
query, and display the new data.
You should also experiment with the presentation of your
data, to make it more readable or more accessible.
Wireless Markup Language (WML) is
XML based and can be viewed via a WAP enabled mobile phone or a PC based WAP
emulator.
So, for some novelty, instead of the XML tags
use WML to display your information system on a mobile device!