How to write a WAP (Wireless Application Protocol) Application

advertisement
A Simple Guide to Writing a WAP (Wireless Application
Protocol) Application
(Note -This article is my view on how to go about doing the above. It has been
biased by my experience with WAP development)
Step 1: Understanding WAP
Read up a little bit about WAP, enough so that you know that the code you
write uses WML (Wireless Markup Language), a language similar in many ways
to HTML (Hypertext Transfer Markup Language). Of course, to write an
application requiring a bit more logic than just creating links, you would need to
know WMLScript, in very simple words; WMLScript is a WAP flavor of
JavaScript.
Also be aware that you can’t just add any image you want to your WAP
Application. You will need to convert it to WBMP (Wireless Bitmap) form. To
convert a .gif or .jpg file to .wmp format, you could use the following website.
www.teraflops.com/wbmp/. This is what I had used. I am not too sure about the
privacy issues, so if you coming up with a very sensitive application, you can use
PaintShop Pro, or Photoshop using a free plugin (MS windows only, at
http://www.rcp.co.uk/distributed/Downloads). I haven’t checked this so I can’t
guarantee it works. The reason I mention it is that if this works I am sure it will be
easy to use. Chris Logan did mention one more option in class that is, that the
Nokia toolkit allows you to create wireless bitmaps.
Step 2: Set-up
Download a SDK (Software Development Toolkit) instead of a separate
editor, emulator and code validator/code tester.
The SDKs I used were:
1. Nokia WAP Toolkit 2.1 (About 19MB)
2. Ericsson’s WAPIDE 3.1 SDK (About 7 MB)
For either one of them, you will need to register with the Company first.For Nokia,
go to http://forum.nokia.com/main.html.And for Ericsson go to
http://www.ericsson.com/developerszone/. Both toolkits need you to have JRE
on your machine. If you don’t have JRE installed on your machine, then Nokia
comes with JRE bundled in with in. If you do have JRE installed and you are
installing the Nokia WAP Toolkit, then go through the documentation that comes
along with the kit to change the path set for JRE to run the kit. Ericsson WAPIDE
SDK does not come with JRE. If do have JRE on your machine, it will look for it
when you install the WAPIDE SDK and automatically set the path for you. If you
need to download JRE, go to http://java.sun.com/j2se/1.3/jre/downloadwindows.html
The Nokia toolkit comes with a good User and Developer manual. It
actually has a lot of working examples on it already. WAPIDE does too in its
latest version. The Developer Manual in the new WAPIDE goes into a lot of
details, which you would need for developing advanced applications.
Step 3: Writing the Application
The basic unit of WML is the card, which specifies a single interaction
between the user agent and the user. Cards are grouped together into decks. (A
deck is the smallest unit of WML). In simple words, in the world of WAP, pages
are called cards. The total collection of these cards is called a deck. Cards have
a specific syntax that must be used. This syntax is as follows:
<card id="name">
<content>
</card>
</wml>
Some tags in WML:
Tags
Description
<onevent> Associates a state transition, or intrinsic event, with a task.
<timer>
Provides a method for invoking a task automatically after some
period of user inactivity.
<do>
Associates a task with an element within the user interface.
<a>
This is the short syntax form for anchors, and can only be used to
define (implied) <go> tasks that require a URL specification.
<fieldset> Allows you to group multiple text or input items within a card.
<img>
Instructs the device to display an image within formatted text. Note
that not all devices can display images.
<input>
Lets the user enter text which the device assigns to a specified
variable.
<select>
Specifies a list of options from which the user can choose. You can
specify either single- or multiple-choice <select> elements
<p>
Specifies a new paragraph and has alignment and line-wrapping
attributes.
The following code is a simple example for generating the message “Hello,
unwired world”. The application is made up of two cards. Copy the code given
below and save the file as hello.wml
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
"http://www.WAPforum.org/DTD/wml_1.1.xml">
<wml>
<card>
<do type="accept">
<go href="#hello"/>
</do>
<p>
Click the Accept Button
</p>
</card>
<card id="hello">
<p>
Hello, unwired world!
</p>
</card>
</wml>
Your output should look like this:
Explanation for the above code:
The first part of the code is as follows:
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
"http://www.WAPforum.org/DTD/wml_1.1.xml">
These lines represent the document prologue. For the most part, just think of it
as a header that you must type at the beginning of every WML deck you create.
The document prologue must contain the following:


An XML declaration. XML is the language that WML is based from.
A document type declarations.
Line 1 (the XML declaration) specifies the XML version. Line 2 and 3 (the
document type declaration) identify the file type as WML and specify the location
of the DTD to use for compiling the file.
The <wml> element designates the beginning of a deck. <card> designates the
beginning of our first card. The <do> element is used to associate an action
(such as going to a particular URL) with a mechanism for invoking it (for
example, pressing the ACCEPT key). The type attribute identifies the generic
user interface mechanism that triggers the specified <do>. In this example, we
have set the type equal to "accept." Thus, the mechanism for invoking our <do>
element is pressing the ACCEPT key.
<go href="#hello"/> gives us the URL to go to after the ACCEPT button is
pushed. In this case, we are to go to the hello card (our second card).
</do>closes our <do> element.
the <p> element to print the phrase "Click the Accept button" onto the display
screen. </card> closes the first card. The deck ends with a closing deck element
</wml>.
Step 4: Testing/Code Validation:
The toolkits compile your code and generate the necessary error messages, if an
error has occurred. If you aren’t using the toolkits, then use any online code
validator.
Step 5: Hosting
You could host WML content on your web server by just adding the
following MIME types:
wml= text/vnd.wap.wml
wbmp= image/vnd/wap/wbmp
wmlc= application/vnd.wap.wmlscript
wmls= text/vnd.wap.wmlscript
wmlsc= application/vnd.wap.wmlscriptc
This is exactly how the MIME file looked in my JSWDK1.0.1 server:
# $Id: mime.properties,v 1.1 1999/03/17 01:17:09 duncan Exp $
# define mime properties here
# <extension>=<mimetype>
txt=text/plain
htm=text/html
html=text/html
gif=image/gif
jpg=image/jpeg
jgep=image/jpeg
wml= text/vnd.wap.wml
wbmp= image/vnd/wap/wbmp
wmlc= application/vnd.wap.wmlscript
wmls= text/vnd.wap.wmlscript
wmlsc= application/vnd.wap.wmlscriptc
Another option is to upload your application on any one of the free
websites that offer WAP Hosting. I put up my application on www.Wapdrive.com.
Of course, you will need to register at these sites before you can upload your
application. A few other websites which provide this service are:
 www.Hoiley.com

www.tagtag.com
That’s all there is to writing a simple WAP application!!! All the best.
Download