WAP/WML (DO NOT USE)
  Home arrow WAP/WML (DO NOT USE) arrow Page 3 - Introduction to WAP using WML, ASP and PHP
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
WAP/WML (DO NOT USE)

Introduction to WAP using WML, ASP and PHP
By: Jean-Baptiste Minchelli
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 8
    2004-04-13

    Table of Contents:
  • Introduction to WAP using WML, ASP and PHP
  • Configuring IIS and Apache
  • Hello World in WMLScript
  • Generating WMLScript with PHP and ASP
  • Conclusion

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    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"

    <WML><CARD id=hello><DO type="accept"><GO href="Hello.wmls#Display('Hello in WMLS')" /></DO>
    Hello world! </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"






    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.

    Our hello.wml script calls hello.wmls. User interaction with the WMLScript is achieved by using a element. When the WMLScript parser reaches the 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 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.

    More WAP/WML (DO NOT USE) Articles
    More By Jean-Baptiste Minchelli


     

    WAP/WML (DO NOT USE) ARTICLES

    - Introduction to WAP using WML, ASP and PHP
    - Introduction to Wireless Access Protocol







    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 1 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek