Apache in a Wireless World

Apache in a Wireless World


August 17, 2000

Originally appearing in WebCompare.

Wireless Internet access has the opportunity to serve, literally, every person everywhere. Delivering wireless content to cellular phones and PDAs is similar to but not exactly the same as serving traditional Internet content. Because of these products' limited physical size and communications speeds, new protocols have been developed to package the Web for the wireless world. WAP and WML are the backbones of wireless Web. Placing the Apache Web server into this picture is a natural and easy fit.

WAP!

While configuring Apache to deliver wireless data is relatively simple, as we will discuss shortly, it is helpful to understand the context of the issues surrounding wireless content delivery.

Land-based Internet communications move data around the world using the TCP/IP protocol. This protocol helps "packets" of data navigate the complex routes across networks, changing paths where necessary to maintain traffic flow across the system. Vendors of wireless communications devices, including such heavyweights as Nokia and Motorola, realized that a data routing system was necessary to push information across wireless networks, which operate with different principles and constraints than physical land lines.

Thus was born the Wireless Application Protocol, or WAP. WAP was designed to push data across the many various types of wireless network topographies in a secure manner, since the wireless space is inherently more vulnerable to eavesdropping than are physical connections. Any operating system can theoretically support WAP. However, the reality is that most devices that will require WAP capabilities will be small in their physical size, like mobile phones and hand-held PDA-style machines.

The consequence of WAP devices' small size is that although WAP as a protocol is perfectly capable of pushing existing data formats such as HTML, these devices are essentially too constrained to properly render documents encoded in these formats, which have been developed with desktop monitors in mind. A companion to WAP was needed then, as well as a defined document format that would render sensibly in the constrained space of small wireless devices.

WML

"And so as wireless begat WAP, WAP in turn begat WML ...", as they might have said in Biblical times had they been writing about content delivery over wireless networks. The Wireless Markup Language, WML, will strike a familiar chord to anyone who has ever worked with the HTML behind most Web pages. In fact, WML is a specific implementation of XML, defining a markup syntax and structure with which users can design pages suitable for a small device.

HTML and WML operate on slightly different underlying metaphors. Whereas HTML is premised on the now-ubiquitous "page" metaphor, WML rests on a "deck of cards" metaphor. Typically, an HTML document represents a single Web page, but a WML document represents a deck within which there can be one or more cards. Navigation within the deck consists primarily of flipping between cards in the deck, either in sequence or via hyperlinks.

Remember that the driving force behind WML is that a wireless device has a small, often tiny, screen and cannot display very much information -- sometimes as little as four or five lines of text. Thus, there's no real space for graphics other than the occasional small logo, most text is the same size, and the screen is often monochrome. So, the real strength in wireless networking is not the capability to replicate land-based Web surfing on the street or in the air, but to target small, focused pieces of data, such as a weather report, a sports score, or a travel reservation.

Like HTML, a WML document is a text document when created as source code. Although this is not a WML tutorial, per se, let's look at a simple WML deck of cards, to get a feel for the type of data that Apache will deliver to wireless devices. We'll set up a WML deck with two cards: the first with a greeting and a link to the second card, the second with some very fictitious "favorite WML pages".


      
<?xml version="1.0"?>


<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">
 <wml>
  <template>
   <do type="back" label="Back">
    <prev/>
   </do>
  </template>
  
  <card id="main" title="Welcome to my WAP">
   <p align="center">I can't say much, since this screen is tiny.<br/>
   Why don't you visit my <a href="#fave">favorite WAP links.</a></p>
  </card>
  <card id="fave" title="Favorite WAP Links">
   <p align="center">These are some WAP sites I would love, if they existed.</p>
   <p align="left">


<a href="wap.cats.com">Tiny cat pictures</a><br/> <a href="wap.weather.com">The weather</a><br/> <a href="wap.jellybeans.org">One click jelly bean ordering</a> </p> </card> </wml>

Configuring Apache

By and large, the Web server doesn't need much tweaking to deliver WML pages to a wireless device. As far as Apache is concerned, it needs only to know how to recognize the MIME type of the file, based on the file's file name extension. Apache will pass this MIME type to the receiving browser and, assuming the browser knows WML, it will know what to do with a WML type file.

Recent versions of Apache can be entirely configured through the file httpd.conf, which is typically located in the apache/conf/ directory, wherever Apache is installed on the server. If you open httpd.conf in a text editor, you can scroll through and view the many, many Apache configuration directives. Ultimately, you will find a section where MIME types are declared. In the default Apache httpd.conf file, this section begins as follows (though it may vary slightly depending on the installation):

#
# AddType allows you to tweak mime.types without actually editing it, or to
# make certain files to be certain types.
#
# For example, the PHP3 module (not part of the Apache distribution)
# will typically use:
#
#AddType application/x-httpd-php3 .phtml
#AddType application/x-httpd-php3-source .phps

AddType application/x-tar .tgz

While not strictly necessary, this is a good and logical place to add WML types to Apache. So, we simply pasted the following lines to our httpd.conf file just after the last line above:


#WML/WAP types
AddType text/vnd.wap.wml .wml
AddType application/vnd.wap.wmlc .wmlc
AddType text/vnd.wap.wmlscript .wmls
AddType application/vnd.wap.wmlscriptc .wmlsc
AddType image/vnd.wap.wbmp .wbmp

The basic WML file is delivered to the browser with MIME type text/vnd.wap.wml. In the statement above, we have told Apache to delivery this MIME type whenever the filename ends in the extension .wml. Similarly, appropriate MIME types are passed for other WML variants. The .wmlc files would be compressed WML files, while .wmls and .wmlsc represent WMLScript (a wireless scripting language) and compressed WMLScript, respectively. Furthermore, .wbmp files represent wireless bitmap files or WBMP, the graphic format that wireless devices support (as opposed to, for example, .gif or .jpg on desktop browsers).

Changes to the Apache httpd.conf file take effect only when the server is launched, so the server must be restarted to save the above changes for the new MIME types to apply. Once done though, Apache is ready to go, and will happily deliver WML and related files to a wireless device.

Development Simulation

You might be thinking, configuring Apache to deliver WML sounds nice in theory, but how can we see it in action? Without a wireless phone, aren't we flying blind?

Fortunately, no. If you're doing any development at all in WML, and also want to test drive your Apache configuration in delivering WML pages, check out Phone.com's UP.SDK package, which includes the incredibly handy UP.Simulator. The Simulator ("UP" stands for "Unwired Planet") displays a virtual cell phone on your desktop, which you can use to connect to and browse any WML page over the Internet (using your normal land-based Internet connection).

The Simulator even includes alternate "skins", or templates for various models of phone, so you can see how WML pages will be rendered on the particular screen size of a certain vendor model. The UP.Simulator is, as Martha Stewart would say were she to prototype WML pages for wireless delivery, "a good thing."