In the same way that Web browsers expect their pages to be delivered in HTML format, WAP microbrowsers expect content in WML format. WML (WAP Markup Language) is simply XML, formatted according to a particular schema. Unlike traditional HTML, which only has a passing resemblance to XML, WML is true XML. It can be processed by a validating parser, and ill-formed content rejected. In principle, WML's stricter syntax rules suggest that there should be less inter-browser variability in formatting than is the case for HTML, but my experience has not borne this out. You should consider testing your WML pages with more than one browser if you want good coverage.
A significant difference between WML and HTML is that a WML document can contain multiple pages (cards, in WAP jargon). When the browser loads the WML document, it will usually display the first page. This will generally contain links to the other pages. HTML, of course, has a single-page format. If you want to display multiple pages, you need multiple HTML files. The difference is for a very good reason. A WAP phone has to establish a dial-up session for each request, and this takes time. It is more convenient, therefore, if the browser can retrieve a set of pages at the same time. WML provides the concept of cards to enable pages to be grouped. Because a WML file contains cards, you will see the phrase `WML deck' used to mean a WML file. This is a trendy piece of jargon, and `deck' means nothing more than `file' in this context.
When a WAP-enabled phone is asked to display a WML page, it needs a URL. The URL has the same format, and meaning, as the URL in any ordinary Web browser. When it has the URL, the WAP phone will dial up a WAP gateway, and then issue an HTTP request for that URL, usually over the public Internet. The gateway collects the response, and returns it to the browser. The browser then hangs up (either immediately, or after a short delay).
The following sections describe step-by-step what you need to do to get a very simple WML page available to WAP phones.
content-type header when the browser requests WML
content. With the Apache Web server, this mapping from file extensions
to content types usually lives in /etc/mime.types,
although you can also use an AddType directive in
httpd.conf. Other
servers have other conventions. As a miniumum, you need to ensure that
the file extension .wml, or whatever else you intend to
use for your WML pages, maps onto the content type
text/vnd.wap.wml. There are other content type mappings you
might need, but this one is a minimum. The problem with using any kind
of shared Web server, either paid for or not, is that you may not be
able to influence the mappings of file extensions onto content types.
However, all modern Apache versions have WAP mappings in the default
mime.types file, so if your ISP uses Apache you should
have no problems.
httpd.conf:
AddType text/vnd.sun.j2me.app-descriptor jad AddType application/java-archive jarOf course, other Web servers will require this configuration as well, using whatever technique they support.
It is not difficult, in principle, to run your own WAP gateway, and this may be useful for a company that wants to provide a private resource to its employees. A WAP gateway is nothing more than a modem and a PPP server. However, to make use of a private gateway requires some reconfiguration of the browser's communications settings, and not every WAP phone user will be happy doing this reconfiguration.
<?xml version="1.0"?> <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml"> <wml> <card id="test1" title="KB WAP test p1"> <p> Test page 1 </p> <p> <a href="#test2">Next page</a> </p> </card> <card id="test2" title="KB WAP test p2"> <p> Test page 2 </p> <p> <a href="#test1">Prev page</a> </p> </card> </wml>
I strongly recommend testing the WML pages, and the Web server, using a WAP browser emulator. Then if things don't go according to plan when you request the page using a microbrowser, you can at least be reasonably confident that the problem does not lie with your Web server or its configuration. I use Deck-it from PyWeb; this is available free of charge for Linux and Windows systems. All you have to do is run Deck-it, and enter the URL of your WML page.
One word of warning, however: do not assume that because you can fetch and display your content using an emulator, you will be able to do so using a real microbrowser. Deck-it, and most other emulators, are far more tolerant of badly-formed WML, and incorrect response headers, than real microbrowsers and WAP gateways are. Remember that a microbrowser is very limited in its memory footprint, so it will parse the WML in a fairly prescriptive way. If your WML isn't up to par, not only will you not get a display, but you won't even get a helpful message. Error messages like `bad response from origin server' may simply mean that your WML is syntactically incorrect. It's worth getting hold of a WML validator, the stricter the better. Alternatively, there is a public WML validation service at HTMLHelp.
Mobile devices that support Java applications (known as midlets) generally provide a number of ways for the user to get applications onto the device. For WAP devices, an interesting approach is to make the applications available for download using WAP protocols. In WAP jargon this is called over the air (OTA) installation. Devices that don't support OTA will use a cable, or bluetooth, or infra-red communication. These installation methods are not relevant to the present discussion, as they are proprietary and not covered by WAP standards. I will concentrate here on making Java applications available OTA.
WAP phones that support OTA installation normally provide the user with at least one of the following methods of download.
<a href="myhost://myurl/app1.jad">Application 1</a> <a href="myhost://myurl/app2.jad">Application 2</a> ...etcThe use of absolute URLs in the
href tags is
necessary, for maximum portability. Mobile devices don't necessarily
assume that a Java application can be obtained from the same directory
as the WML file that references it, even if that is the case. In
other words, even if your JAD and JAR files are in the same directory
as the WML files, you'll still need absolute URLs to the JAD files.