topbanner1.gif (6620 bytes) topbanner2.gif (8181 bytes) topbanner3.gif (5932 bytes) topbanner4.gif (4322 bytes)

Cafe Wireless Application Protocol (WAP)                                                   <main>

intro.jpg (9489 bytes)

  
Introduction to Mobile Internet,
WAP and GSM

  
Powered by:

wapcom.jpg (5088 bytes)

Quick beginnerīs guide to creating your WAP site

Most of you will probably find that itīs easier to learn by just going ahead and experiment rather than reading lots of documentation first and then try. This article will seem very long, but it will in fact be short, and to the point. Those of you who already have prior knowledge of WAP will notice some white lies and shortcuts, which you are kindly asked to ignore. The point of this article is not to provide detailed technical information, but to help people who are new to WAP up to a point where they can start experimenting on their own.

September 13 2000

In a broad, general view, there's not much difference between "the web" and WAP. Actually, WAP is just as much part of "the web" as your typical PC based browser such as Netscape and Internet Explorer. For this introduction we will call normal web servers and web browsers "the web".

If you think of "the web" as a concept, with its specifications and protocols explaining how things must operate in order to do what we want them to do, you can think of WAP as a concept too.

WAP is a set of specifications and protocols which explain how things should and must operate in order to be WAP. The difference between "the web" and WAP is of course that WAP is meant for wireless devices, including but not limited to mobile phones. In the wireless environment everything is simpler and smaller. You have very narrow bandwidths, very little power from batteries to drive very small processors. Everything must be smaller and simpler. If you've followed the hype on WAP you will probably have heard that WAP will die when faster connections become available, such as GPRS, but this just isn't the case. These higher bandwidth technologies will only improve the services that will become available through WAP.

Unfortunately the WAP concept is plagued by much hype. Many of you will no doubt think of WAP as the same as a "mobile phone from which you can surf the web", and this in a way true, but not as you think. WAP is very much in it's infancy, and expecting things that will blow your socks off today is probably going to end in disappointment. WAP is more or less at the evolutionary stage that "the web" was at about five years ago. In short, the limits of WAP today is plain text with some simple styling like bold and italics, but only on some devices. Monochrome images on displays that are typical 100 by 40 pixels. No audio, and no fancy animations. But this is today, and many companies are working hard on exciting new technologies to make WAP as saucy as anything you can imagine.

In order to get a grasp on WAP, there are a few things you need to know about how it works.

On "the web", a "web page" is a file (document) stored on a web server, and this file is sent to your web browser when you request it. In WAP, the documents are called decks, and they are also stored on webservers. Each deck contains one or more cards, and the content of each card is what is normally displayed in the WAP browser window, although the display windows is scrollable. On "the web" the markup language for documents is HTML. In WAP the markup language is WML. The two might look very similar, and for this we'll pretend that they are very similar (but there are some rather important differences).

On "the web" your web browser will usually talk to a web server directly to ask for a certain page. In WAP, there is another device involved which is called a WAP gateway. This device sits somewhere on the network between your WAP device and the webserver and helps the webserver send data to the WAP device and vice versa.

Also, although a normal web server is commonly used to serve WML decks, the web server will in most cases need to be slightly reconfigured in order to serve the WML decks correctly. This involves setting the so called MIME types on the server, and for more information on this, you can have a look at this document. The person who owns the webserver you are using should be able to help you with this.

A very simple HTML page may look like this:

  <H1>Hello world!

The HTML code above may not be correctly formatted. First of all the end tag </H1> is missing, and there should really be a <HEAD> and <BODY> section etc etc. However, all normal web browsers will be able to display the page above correctly.

In WML it's a different story. The WML code is much more strict, meaning that you must follow the formatting rules, or you simply won't be able to display it. There's no room for error. The reason for this is that the so called WAP gateway, with very little intelligence, will convert the WML code to a "compressed" format before it is sent to the WAP browser to save time.

The same as above written in WML would look something like this:

  <?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="mycard" title="My first card">
  <p>Hello world!</p>
  </card>
  </wml>

Most important is the header. The absolutely first character that is received by the WAP gateway, must be the < character that starts the line <?xml version="1.0">. Any other character (even a space or a carriage return or other will break the card).

If you want, you can now copy the code above and paste it into your favourite text editor, for instance Notepad. Save the file on your computer and call it world.wml. Notice the .wml file extension. This is the common file extension for WML files. By now, you'll want to look at this file in a WAP browser. Go to this page and pick a software based browser that can run on your computer. Stay away from the SDKs and the Toolkits for now. These are development tools, and really overkill for your very first WML deck. WinWAP is a good starter application, but as you get more advanced, the UP.SDK is a recommended choice. WinWAP can also open and display WML decks that are stored on your local computer, which means that you can test them without having to place them on a webserver.

Since the WML code above is extremely simple and should work on the first try, run WinWAP and open the file. If you see Hello world! in the WinWAP display, you've just made your very first WAP application. Congratulations!

The WAP components in the chain between you and the webserver, the WAP gateway and the WML browser are as previously mentioned very strict when it comes to syntax errors. If you get any problems, strip the code down to the bare minimum. This is especially true for the first two lines of code which are the so called XML and DTD definitions, and if you type the code in manually there is lots of room for error.

If you're using a "software" WML browser like WinWAP or WapMan, which do not involve the WAP gateway, to test the code, you might find that it works on these even with some errors, but on a real WAP device it will not. The WAP gateway is much more strict than the emulators.

Play around with the code above. Change the title of the card by setting the title parameter in the card tag to something else. Change the text in the card and add another paragraph of text. For instance to something like this:

  <?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="mycard" title="My second card">
  <p>Hello again world!</p>
  <p>I'm back again with another WML deck created from scratch!</p>
  </card>
  </wml>

Notice the <p> and </p> at the beginning and end of each line of text. The <p> tags are typically used to begin a new paragraph of text, and as previously mentioned, all WML tags much be closed, in this case with </p>. Actually, that's not quite true. Some WML tags do not have a closing tag. Examples are <br/> (break) which is used to break a line of text, and <img/> which is used to insert an image in the text.

Let's try to use both these tags right away. But wait! As you already know if you've paid attention so far, WAP devices currently only support monochrome images. Further, they only support images in a special wireless image format called WBMP. Not GIFs, not JPEGs. To test the <img/> tag you'll obviously need a WBMP image. For now we'll use an already made WBMP image. The image is what you see below. In GIF format on the left, and in WBMP format on the right.

GIF format WBMP format

There are many tools available that will let you convert from one image format to another, and there's a list available here.

Now download your test image by clicking here and save the file as testimage.wbmp.

Finally! Let's use the image in a WML deck.

  <?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="mycard" title="My girlfriend">
  <p><img src="testimage.wbmp" alt="Pretty girl"/></p>
  <p>Check out my girlfriend!<br/>(I wish :-)</p>
  </card>
  </wml>

First of all notice that there is no closing tag for the <img> tag, but as you can see, the tag ends with a / (slash) unlike the tags that need a closing tag. In short the <img> tag does not need a closing tag. Then see the alt parameter to the <img>. This parameter is required because not all WAP devices can display images. The text inside the alt parameter will be shown instead.

The next reasonable step would be to play around with the WML decks you have made so far. Then download the WML Reference Specifications which lists all the WML tags and what they do. (Adobe Acrobat Reader is required to read this and many other specifications related to WAP. Better download it right away.)

Most WAP specification documents are unfortunately pretty boring reading for beginners, and lots of caffeine is required to read them from beginning to end. Unlike this article, they need to be exact and contain no errors or omissions. As you get more advanced, the WAP Specifications from WAP Forum are required reading. WAP Forum are after all the group who develop WAP. For a slightly more human approach to getting into WAP, check out The Independent WAP/WML FAQ.

Don't be afraid to ask others for help. Join mailing lists that cover WAP. We recommend the WML and WMLscript Programmers as it has a high number of people who are both good programmers and willing to help.

Good luck!

Copyright Reserved Macro Kiosk Sdn Bhd (236716-T)