|
Wireless networks are mainly used for voice communication. Wireless operators, however, are interested in delivering data over wireless networks. Having become a new buzzword, WAP (Wireless Application Protocol) is designed specifically for delivering Internet data over wireless networks. This article introduces you to WAP and its related technologies (WML, WMLScript, and so forth), and shows you how to develop wireless applications using Java technology. Most Internet technologies have been designed for desktop and large computers running on reliable networks (with relatively high bandwidth). Handheld wireless devices, however, have a more constrained computing environment compared to desktop computers. Handheld devices tend to have less memory, less powerful CPUs, different input devices, and smaller displays. Further, wireless networks have less bandwidth and more latency compared to wired computer networks. WAP, the Wireless Application Protocol, was designed to take advantage of the several data-handling approaches already in use. WAP integrates the Handheld Device Markup Language (HDML) and the Handheld Device Transport Protocol (HDTP) developed by Unwired Planet (now known as Phone.com), as well as Nokia's Smart Messaging Protocol (SMP), and Ericsson's Intelligent Terminal Transfer Protocol (ITTP). WAP services can be hosted on Web servers using technologies such as Java servlets and JavaServer Pages(JSP). In this article, I show you that WAP and Java are complementary, not competing, technologies. WAP is meant for cellular phones, and Java aims at more sophisticated network terminals. The WAP platform is an open specification that addresses wireless network characteristics by adapting existing network technologies (and introducing new ones where appropriate) to the special requirements of handheld wireless devices. Therefore, WAP intends to standardize the way wireless devices (mobile phones, PDAs, and so forth) access Internet data and services. WAP's reuse of existing Internet protocols will ease the development of WAP services for Java and other Web developers. To facilitate the delivery of Internet data to wireless devices will certainly lead to the introduction of new technology. For example, wireless devices have small screens compared to desktop computers, and therefore HTML (which is visually rich) is not appropriate for small screens. The small screen and the computing power, which is increasing, represent a limiting factor in running complicated Java applications with intensive graphics. However, efforts are being made for having a compact subset of the Java language suitable for mobile applications. In this article, you learn how to develop WAP applications using Java servlets and Java Server Pages. But first, I describe the WAP platform and how it incorporates several technologies that are similar to existing ones but that have been designed specifically for wireless devices. The WAP Architecture The WAP standard defines two essential elements: an end-to-end application protocol and an application environment based on a browser. The application protocol is a communication protocol stack that is embedded in each WAP-enabled wireless device (also known as the user agent). The server side implements the other end of the protocol, which is capable of communicating with any WAP client. The server side is known as a WAP gateway and routes requests from the client to an HTTP (or Web) server. The WAP gateway can be located either in a telecom network or in a computer network (an ISP). Figure 1 illustrates an example structure of a WAP network.
In Figure 1, the client communicates with the WAP gateway in the wireless network. The WAP gateway translates WAP requests to WWW requests, so the WAP client is able to submit requests to the Web server. Also, the WAP gateway translates Web responses into WAP responses or a format understood by the WAP client. The WAP Programming Model The WAP programming model is similar to the Web programming model with matching extensions, but it accommodates the characteristics of the wireless environment. Figure 2 illustrates this model.
As you can see, the WAP programming model is based heavily on the Web programming model. But how does the WAP gateway work with HTML? In some cases, the data services or content located on the Web server is HTML-based. Some WAP gateways could be made to convert HTML pages into a format that can be displayed on wireless devices. But because HTML wasn't really designed for small screens, the WAP protocol defines its own markup language, the Wireless Markup Language (WML), which adheres to the XML standard and is designed to enable powerful applications within the constraints of handheld devices. In most cases, the actual application or other content located on the Web server will be native WAP created with WML or generated dynamically using Java servlets or JSP. In HTML, there are no functions to check the validity of user input or to generate messages and dialog boxes locally. To overcome this limitation, JavaScript was developed. Similarly, to overcome the same restrictions in WML, a new scripting language known as WMLScript has been developed. I'll cover more on WML and WMLScript in later sections. The WAP Protocol Stack To minimize bandwidth requirements, and guarantee that a variety of wireless networks can run WAP applications, a new lightweight protocol stack called the WAP protocol stack was developed. Figure 3 illustrates this stack protocol and also shows a comparison to a Web-based protocol stack. (The layer acronyms can be translated to Wireless Application Environment, Wireless Session Protocol, Wireless Transaction Protocol, Wireless Transport Layer Security, and Wireless Datagram Protocol, respectively).
The WAP protocol stack has four layers: session layer, transaction layer, security layer, and datagram layer. Note that the WAP protocol is designed to operate over a variety of bearer services, including Code Division Multiple Access (CDMA), Cellular Digital Packet Data (CDPD), and so forth. WML The Wireless Markup Language (WML) is an XML-based markup language that was designed to describe how WAP content is presented on a wireless terminal. WML differs from HTML in the following:
Based on these differences, WML provides a smaller, telephony-aware set of tags that make it more appropriate than HTML for handheld wireless terminals. Similar to HTML, though, with WML you can give the user input options and specify how the user agent should respond when, for example, the user presses a key. The Genesis of WML The basic unit of WML is the card that specifies a single interaction between the user and the user agent. Multiple cards are grouped together in decks. A deck is the topmost element of a WML document. When the user agent receives a deck (by downloading the complete deck), it activates only the first card in the deck. Listing 1 shows a sample WML document with a single card: Listing 1. Example1.wml
When viewed on a WAP-enabled phone, Listing 1 is rendered and displayed as shown in Figure 4.
As I mentioned before, WML is based on XML. Therefore, a deck has to be a
valid XML document, which implies that a WML document (as the one shown in
Listing 1) should start with the standard XML header and the reference to the
WML DTD. The Now, take a look at an example that has two cards and uses other WML features. Listing 2 shows the Ottawa City Guide example. Listing 2. Example2.wml
This example was developed using the Ericsson WapIDE (WAP integrated development environment). WapIDE is shown in Figure 5 along with the output of Listing 2.
The example in Listing 2 has two cards: city and food. When a device receives this deck, it loads the first card automatically as shown in Figure 6. Once the city card is loaded, you can navigate through it using the soft key on your device. Figure 7 shows what happens when the Restaurants option is selected.
Navigation in this example is implemented using anchors
(
This is identical to:
In the preceding example, I have used
Therefore, Graphics in WML
Like HTML, WML has an
In the preceding food card, I am using the image
There are other tags defined in WML, such as WMLScript WMLScript, which is based on ECMAScript (the standard for JavaScript), is a language that you can use to provide programmed functionality to WAP applications. It is part of the WAP specification, and it can be used to add script support to the client. The main difference between WMLScript and ECMAScript is that WMLScript is compiled into byte code before it is sent to the client. The main reason for this is of course to cope with the narrowband communication channels and to keep client memory requirements to a minimum. You can use WMLScript to check the validity of user input, but most important, you can use it to generate messages and dialogs locally, so error messages and confirmations can be viewed faster, and to access facilities of the user agent -- for example, it allows the programmer to make phone calls, access the SIM card, or configure the user agent after it has been deployed. WAP and Java WAP applications, which will be hosted on normal Web servers, can be written in WML and WMLScript. But you can also write them using existing Web technologies. Dynamic WML documents can be generated by CGI scripts, servlets, JavaServer Pages, Active Server Pages, Perl, Tcl, and so forth. In other words, you can implement your own first WAP service in Java, with the help of the WAP technologies described earlier. In this section, I am going to show you how WAP applications can be easily developed in Java using servlets and JSP.
WAP and Servlets
Listing 3 shows an example of a simple servlet that displays the current date and time on a wireless device when invoked. Listing 3. MobileDate.java
Most of the preceding code uses pure WML tags, with the exception of the line:
This line ensures that the correct MIME type is set for the WML document. Please refer to the Web Server Configuration section, which follows, for more information on how to add MIME types. The rest of Listing 1 basically outputs a WML document. When this servlet is invoked from a mobile phone, it displays the current date and time as shown in Figure 8. For this example, I have used Apache and JServ.
By the way, cookies are useful for maintaining state and keeping track of users' sessions. Cookies are part of the WAP specification, but unfortunately, are not yet implemented by all WAP browsers. The Nokia 7110 doe s not yet support cookies. However, Phone.com's UP.Simulator does support them.
WAP and JSP
The following example is similar to the preceding servlet example; it displays the current date and time on a wireless device. Listing 4. mobiledate.jsp
Again, you need to set the MIME type correctly to make sure that the mobile phone browser is able to parse the contents. The following line sets the MIME type to a WAP/WML document:
Once this JSP document is invoked, it displays the current date and time as shown in Figure 9.
JAWAP JAWAP (which was initially known as JAFFA) is Ericsson's Java Framework for WAP. It is based on RMI and servlets. I personally found JAWAP to be a bit complex to use; for example, you have to develop several classes to get a simple application up and running. Further, it doesn't seem to be stable. Using servlets or JSP to develop WAP applications is much easier than using JAWAP. If you are curious about JAWAP, however, you can download it from Ericsson's Website in Resources. Web Server Configuration
When a regular Web browser receives a page, it has to distinguish between
HTML, image data, audio, and video. To enable that, with every response from
the Web server, a piece of header information with every file comes down to
the browser. This piece of information is known as MIME, which stands for
Multipurpose Internet Mail Extension. Some of the common MIME types include
To enable the Web server to serve WAP documents, it needs some new MIME types. The types that WAP requires are:
Adding these MIME types varies from server to server. Check the documentation for the Web server you are running, and you'd be surprised how easy it is to add these new MIME types. In Apache, the preceding MIME types should be added to the httpd.conf file. WAP Emulators and Development tools In order to access WAP services, you need a WAP-enabled phone like the Nokia 7110, Siemens S25, Ericsson R380, or Alcatel OneTouch. However, as far as I know, there are no WAP-enabled phones in the North American market yet. The Nokia 7110, the first WAP-enabled phone, has been available in Europe, Asia, and Africa for several months now. The joke in the American wireless market is that WAP stands for Where Are the Phones. Still, I think you will start seeing WAP-enabled phones in the American market sometime this summer. If you are in North America and you'd like to start with WAP, you can use an emulator for now. There are several emulators available. In this article, I have used the ones from Ericsson and Nokia. But there are others available from Motorola and Phone.com. See Resources. As for development tools, I have used Nokia's WAP ToolKit and Ericsson's WapIDE, and I liked them both. They are basically used to assist in developing WAP applications. But the major advantage of them is that they come with WAP simulators with which you can test your WAP application. Again, other development tools are available in Resources. Conclusion WAP is an open specification for delivering Internet content to wireless devices. In this article, you have learned the basics of WAP, WML, and WMLScript. I have provided examples of sample WAP applications to give you a flavor of WAP, and I have demonstrated how you can develop WAP applications in Java using servlets and JSP. WAP is a new technology with a promising future (or so I hope). If you would like to discuss your experiences or ask questions about using WAP and Java, please join my short-term community discussion on this topic. Hope to hear from you there! Resources
Back To Top | |||||||||||||||||||||||||||||||||||
|
| ||||||||||||