Home arrow ASP arrow Page 3 - Introduction to WAP using WML, ASP and PHP
ASP

Introduction to WAP using WML, ASP and PHP


As technology changes, so do the tools that we use to manipulate it. Today the Internet is available from a number of devices, both connected and portable. In this article Jean shows us how to use the OpenWave SDK to create WML scripts. He also shows us how to configure IIS and Apache for WAP document requests.

Author Info:
By: Jean-Baptiste Minchelli
Rating: 5 stars5 stars5 stars5 stars5 stars / 73
February 22, 2002
TABLE OF CONTENTS:
  1. · Introduction to WAP using WML, ASP and PHP
  2. · Configuring IIS and Apache
  3. · Hello World in WMLScript
  4. · Generating WMLScript with PHP and ASP
  5. · Conclusion

print this article
SEARCH DEVARTICLES

Introduction to WAP using WML, ASP and PHP - Hello World in WMLScript
(Page 3 of 5 )

WAP currently uses WML (Wireless Markup Language), which is based on XML (eXtensible Markup Language), and WMLScript, which is based on ECMAScript.

If we compare WML to a Web application, we could say that WML plays the role of HTML (document formatting), and WMLScript is like JavaScript (implemented in the same way as a client-side scripting language).

The WAP Forum has just released version 2.0 of the WAP standard. This release includes support for 3G (third generation) wireless networks, as well as XHTML based client side languages. Enough about that however, I will go into more about the WAP standard and its governing architectures in another article.

Using notepad, create a new file named hello.wml and save it in a directory that can be processed by either your IIS or Apache server. Enter the following code into 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 id="hello">

<p>

<do type="accept">

<go href="Hello.wmls#Display('Hello in WMLS')"/>

</do>

Hello world!

</p>

</card>

</wml>


Create another file called hello.wmls and save it in the same directory as hello.wml. Enter the following code into hello.wmls:

extern function Display(msg)

{

Dialogs.alert(msg);

return;

}


At this point we've configured our web server, and we've also create two WML-based scripts. Load the OpenWave SDK and enter http://localhost/hello.wml into the address bar, replacing localhost with the name/IP address of your web server.

Click on the go button or press enter. OpenWave will contact our web server and request hello.wml, which displays "Hello in WMLS" on the WAP emulator that comes bundled as part of the OpenWave SDK. Hello.wmls also displays the same text, but is a browser result of executing the .wmls script.

Here's how the output looked on my screen:

Our WMLScript in action!

As you can see from my screen shot, I've loaded hello.wml into the OpenWave IDE and ran it from there, which you can do also. Notice in the lower frame that OpenWave formats the WML as well-formed XML, showing us that WML is indeed based on XML.

You don't have to use the OpenWave IDE to test your WML. If your web server is connected to the Internet then you can use a WAP-enabled device to call up your WMLScript and it will be displayed exactly how it is in OpenWave.

Before we move on to see how we can generate WML dynamically using PHP and ASP, let's talk a bit about the code that makes up our hello.wml script.

<?xml version="1.0"?>

<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.WAPforum.org/DTD/wml_1.1.xml">


A valid WML document must start with a line corresponding to the DTD matching the WML implementation currently used in the document. We've used the XML-based WML DTD, which exists on the WAPforum.org server.

WML has been created for the wireless world: low bandwidth, small screen and non-ergonomic devices. It's for this reason that we have to deal with decks and cards, which are the proper names for the contents of a WML document.

A deck is a succession of cards (screens), which provides navigation options for the user. WML is retrieved differently that HTML is from a server, because multiple WML pages are retrieved in one (downloaded) document. During the navigation through the deck, clients don't have any interaction with the server. In our example, we have created just one card in the deck.

[Note] The id of each card must be unique in the deck, because this id allows navigation between cards. [End Note]

Our hello.wml script calls hello.wmls. User interaction with the WMLScript is achieved by using a <do> element. When the WMLScript parser reaches the <go> element, it retrieves the contents of its href attribute, which is hello.wmls.

If you take a look at the code in hello.wmls, you will see that it resembles JavaScript/C++ code. The Dialogs.alert() function simply outputs a string to the WAP device, which in our case is the OpenWave emulator.

In hello.wml, we call the Display function (which is part of hello.wmls) by adding a hash character, function name, and single string argument after the URL for the href attribute of the <go> tag:

<do type="accept">

<go href="Hello.wmls#Display('Hello in WMLS')"/>

</do>


As I'm sure you'll agree, this is a very smart way to invoke functions from other WML scripts. Because WMLScript is client-side, it's useful for simple calculations and manipulations, such as currency conversion and so on. WML also has a method for passing information (variables) between cards, however that's outside the scope of this article.
blog comments powered by Disqus
ASP ARTICLES

- Central Scoreboard with Flash and ASP
- Calorie Counter Using WAP and ASP
- Creating PGP-Encrypted E-Mails Using ASP
- Be My Guest in ASP
- Session Replacement in ASP
- Securing ASP Data Access Credentials Using t...
- The Not So Ordinary Address Book
- Adding and Displaying Data Easily via ASP an...
- Sending Email From a Form in ASP
- Adding Member Services in ASP
- Removing Unconfirmed Members
- Trapping HTTP 500.100 - Internal Server Error
- So Many Rows, So Little Time! - Case Study
- XDO: An XML Engine Class for Classic ASP
- Credit Card Fraud Prevention Using ASP and C...

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 

Developer Shed Affiliates

 




© 2003-2014 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials