|1.13 Can you show me some simple example code?|
Most of you will probably find that it's easier to learn by doing rather than reading lots of documentation first and then try. I still recommend that you take at least a quick look at this FAQ before starting. This section of the FAQ will be short, and to the point. Those of you who already have prior knowledge of WAP will notice some white lies and shortcuts. Ignore them please. This section is for "newbies".
It's virtually impossible to get a grasp on WAP without some prior knowledge of things like "the web", HTML and web servers. This is required for this introductions. If you don't know any HTML, stop now and learn some before returning. Sorry.
Think of WAP as a concept. It's a set of definitions on how things should work. First of all forget all the hype you've heard. We'll stick to simple text, simple images and a simple input form.
On "the web", a "web page" is a file (document) stored on a web server. In WAP, the documents are called decks, and each deck contain one or more cards. The content of each card is what is displayed in the WAP browser window. On "the web" the common language for documents is HTML. In WAP the language is WML. The two look very similar, and for this we'll pretend that they are very similar (but they are in fact not).
A very simple HTML page may look like this:
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. For instance, all tags must be closed. In other words, it must be correctly formatted and there's no room for error. The reason for this is that a 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.
The same as above in WML would be something like this:
<?xml version="1.0"?> <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://..."> <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 browser 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 take the code above and put it into a file called
Some of these software based browsers can open the files on a local drive, and that's good for testing, but you'll sooner or later want to look at this page from the internet. For that you need a plain old web server. Before you start with the web server, there's something you need to learn called MIME types.
When a browser requests a page from a web server, the web server sends out a string of information to tell
the browser what kind of data the browser is about to receive. When your standard web browser asks for
a web page, which are usually file with the
Have a look at this section which will give you a bit more details on how to configure a web server to handle the WML files.
The WML code above can be used to test the configuration, and when it works, you're ready to rock.
The WAP components, the WAP gateway and the WML browser are usually 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 XML and DTD definitions, and if you type the code in manually there is lots of room for error. In the current version of WAP, the first 21 characters of code must be as follows. There must be no spaces, carriage returns, line feeds or other characters except what's below.
If you're using a "software" WML browser like WinWAP or WapMan to test the code, it still might not work on a real WAP device. Real WAP devices are much more strict than the emulators.
|[ Main ] [ 01 - General ]|
© Copyright The Wireless FAQ. All Rights Reserved. Terms | Site Map