From the June 2000 issue of MSDN Magazine.
This article may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist. To maintain the flow of the article, we've left these URLs in the text, but disabled the links.
Info on the Go: Wireless Internet Database Connectivity with ASP, XML, and SQL Server |
|||||||||||||||||
Srdjan Vujosevic and Robert Laberge | |||||||||||||||||
|
|||||||||||||||||
here's a new trend in wireless telecommunications, Internet, and database integration: Internet connectivity via handheld devices. More people are buying wireless handheld devices such as cellular phones and personal digital assistants (PDAs), and they demand access to online resources. This article discusses the missing link used to connect these portable devices with the vast resources of the Internet, focusing on connecting a cellular phone to your database-driven Web site. Components of a Wireless Web ServiceThere are four basic components that make up a wireless Web service: UP.Browser phones, WML, UP.Link Server, and WML services.UP.Browser phones are handheld devices with special software that replace conventional Web browsers. The WML language is a programming language consisting of a set of statements that defines what the UP.Browser phone displays in its window and how it interacts with the user. Instead of Web pages, the wireless world uses decks consisting of cards. Here is an example of a static WML deck:
It's possible to create applications based only on static WML decks, but real-time information can only be provided to users by creating dynamic WML decks. This can be achieved by using CGI, the Java language, ASP, or any scripting language that can query databases dynamically and format the output to conform to WML standards. In effect, dynamic WML programming is the key to database-driven wireless connections. How Wireless Communication WorksUnlike the classic Web scenario where communication is direct to the Web server, wireless Web communication requires an intermediate server to translate messages between the cellular phone or other handheld device and the Web server (see Figure 1). This intermediate server also translates the responses from the database server back to WML display commands (whether you're using ASP, the Java language, or Perl).Certain additions to your Web server must be made to accept these new types of requests. You must add a new MIME type of text/vnd.wap.wml, with a file extension of wml. You must also add a 1-bit black and white bitmap image if you plan to use graphics in your service. This requires its own MIME type of image/bmp, with a file extension of bmp. Other useful MIME types include application/x-up-alert and application/x-up-cacheop. By the way, if you don't have a cellular phone or another Web-enabled handheld device, don't worryâ€"Phone.com and Unwired Planet (creators of the UP.Browser technology) provide an excellent emulator for cellular phones. Simply register as a developer at https://updev.phone.com and download the SDK. There are separate versions for HDML and WML. Here's a possible technical scenario. Imagine you've started a company, just you and your partner. You've invited a potential investor to dinner to present your business plan. If you succeed, you're in business; if not, it's back to the cubicle. You're both waiting on some very important data you've been gathering all day on your system in the office across town. No one is in the office because you both must be present to deal with the investors, but you must get that data in a matter of minutes. What do you do? Simple. You call up the database server using the wireless Internet capabilities from your cellular phone and query the database. The idea is to call your SQL Server and invoke a stored procedure or issue a SQL statement that will query the database and send the results back to your cell phone. Before you can do this, there are some preparatory steps you must take. Creating the Sample DatabaseThe type of back end database you will use depends on the type of application you are going to connect to the wireless network. From the Web server's perspective, this is not an issue as long as there is a standard method of connectivity available for the database, such as ODBC, Data Access Objects (DAO), or ActiveX® Data Objects (ADO).In this example, we'll use a Microsoft® SQL Serverâ„¢ 7.0 database called WAPTest. With minor modifications, this script will work on SQL Server 6.5 and Sybase servers. Use the script in Figure 2 to create a database. Then use the scripts in Figure 3 to create the required tables. The following simple WISQL scripts can be used to populate the security and items tables:
To avoid any additional costs (since some ISPs charge for DSN entry creation for database connectivity), we'll connect to the database using a DSN-less connection from the ASP pages. The WMLSecurity table will be used for security to log into the SQL Server database, and the WMLItems table will be used as the main reporting table. Implementing the WML DeckOur sample code will be a combination of four pages; two WML decks and two dynamic ASP pages will enable our IS professional to log in and query the database. Then the database will send the results, reformatted in WML, to the partner's cell phone without the client ever knowing what happened.Let's start by creating the WML deck, which will serve as the main gateway. The code (shown in Figure 4) will also include a sample telephone directory, which is important for the technical support aspects of the design. Here are the screen images produced by the code in Figure 4. If one partner would like to reach some of the people in the telephone list, say technical support or the boss, he would select option 1, which would display the following screen: The following code represents the login.wml deck:
This code will be invoked from the following line in the WML program shown in Figure 4.
By simply pressing 2 key on the keypad of your cell phone, the deck will allow the user ID and password to be passed to the ASP page, which in turn will log in and establish a SQL Server session. The login information will be passed to the login.asp routine, which will execute the ADO connection to SQL Server. Note that it is very important to separate passed parameters with the HTML equivalent for an ampersand, &. The login.asp routine is invoked from this line in the login.wml code:
Due to limitations in the size of the information that can be passed to WAP-enabled devices, you should try to use simple but clear messages for users. Also, use drilldown menus as much as possible to avoid the cumbersome data entry on cellular phones.
Great, we're in! Now she can execute the SQL statement, which will produce the anticipated results on the cellular phone window in real time.
Note that in the DDL for the WMLItems table, a field called WhoCanSee also exists. In this example, WhoCanSee will not be used, but its purpose is to limit access to certain records only to authorized personnel. Getting the Required DataThe following four screens show the results from all of our queries. They are the dynamic representations of the data from the SQL Server table. The partner now has the results in real time on his cellular phone. The investors have no idea of the work involved, and yet the results are accurate and up-to-the-minute. In conclusion, the deal is successful, the potential investor is happy with the technology, and the partners are in business! |
|||||||||||||||||
For related articles see: https://www.phone.com/products/upsdk.html https://msdn.microsoft.com/downloads/samples/Internet/xml/adoxml/sample.asp Background information: https://www.microsoft.com/ISN/telco/default.asp https://www.microsoft.com/ISN/ind_solutions/wireless_data.asp Srdjan Vujosevic and Robert Laberge are the creators of WorldJobMart.com, one of the first Internet job sites available on wireless handheld devices. They're also creators of WaveDev.com, a venture that specializes in wireless-enabling Internet sites using WAP, WML, and HDML. The authors can be reached at authors@wavedev.com. |