WAP with a Microsoft Spin
Microsoft was an early and active member of the WAP Forum, the industry consortium responsible for the standard. Microsoft aims its WAP interest at providing software products and services for the mobile Internet market. The intent is for those products to transitionally support both HTTP access and WAP access to Microsoft's core Windows services. As part of the .NET developer initiative, Microsoft has released the Mobile Internet Toolkit (or simply, MIT), which addresses many of the issues raised when attempting to target a wireless application for both WAP and more traditional Web platforms. MIT provides application developers with a programming interface that targets both platforms.
WAP was designed to enable a Web-like experience given the limited capabilities and bandwidth of wireless telephone technology. The low-power displays of mobile phones only allow a few lines of text and simple graphics to be displayed, and the digital data link is usually rated at no more than 9.6 or 14.4 Kbps for most service providers. WAP defines a client/server applications protocol, similar in many respects to the Web's HTTP. HTTP is designed to operate over TCP/IP-based networks, whereas WAP is designed to work with most wireless telephony networks, such as code division multiple access (CDMA) and global system for mobile communications (GSM). HTML is the markup language used by most HTTP-based browsers. WAP defines its own markup language, Wireless Markup Language (WML), for formatting text on WAP devices. Though there are several differences, at a higher level, WAP and HTTP share most of the traditional client/server Web-browsing concepts.
The MIT abstracts these concepts into a single, server-based application interface. At runtime, MIT components can distinguish the request signatures of WAP and HTTP client platforms and provide the correct content format on the fly.
MIT Web Controls Do the Hard Work
MIT components are Web controls. The .NET framework has extended the Active Server Pages (ASP) concept with the notion of server-side controls defined as templates on a Web page. When a page is requested, the ASP.NET engine expands the page's Web controls into content that can be rendered on a browser. The controls themselves may invoke application logic when rendered. Server-side ASP scripts are also used to wire-up server controls to application components. The simple MIT page in Figure 1 contains a single control to display a message. The code shows the static message "Hello!" on the browser. You could easily customize the message with a simple script, as in Figure 2. When browsing Figure 2 with a certain popular desktop browser, the message "Hello IE user!" is shown.
<%@ Register TagPrefix = "Mobile" Namespace="System.Mobile.UI" %>
Figure 1: This simple MIT page displays "Hello!"
<%@ Register TagPrefix="Mobile" Namespace="System.Mobile.UI" %>
protected void Page_Load(Object sender, EventArgs e){
if (!IsPostBack)
MyLabel.Text = "Hello " + Request.Browser["Browser"] +
" user!";
}
Text="This will be overwritten in Page_Load" />
Figure 2: A slight customization of the code in Figure 1 determines the browser in use.
Note the first line of the pages in these examples includes the directive Page Inherits="System.Mobile.Ui.MobilePage". This means the page inherits the events, properties, and methods of the MobilePage class. In Listing 2, C# code has been added to handle the MobilePage's Load event. This code will be called when the ASP.NET engine accesses the page. The code uses the Request property of the MobilePage to obtain the name of the browser being used and inserts this information into the Text property of the MyLabel control.
Although the pages in Figures 1 and 2 bear little resemblance to valid HTML, the pages produce valid HTML when accessed via HTTP. The "magic" is that the pages also produce valid WML when accessed by a WAP device. The Mobile:Form control is an abstraction of the page or form constructs of HTML and the card construct of WML. In WML, a card is similar to a page when rendered. However, several WML cards may comprise a single WML page, thus MIT applications often contain several Mobile:Form controls on a single page. The Mobile:Label control models a simple text string, which can be static as in Figure 1 or manipulated by code as in the Page_Load handler of Figure 2.
A MIT Application
ASP.NET and MIT provide numerous other Web controls and objects for building complete, robust applications. Using the MIT, the XML classes of the .NET framework, and one of my own Component Object Model (COM) components, I built a small, three-tiered, browser-based application that supports WAP and HTTP. The source code for this application can be downloaded from the MC Press Web site (see the sidebar at the end of this article for details). The application allows the user to query for a certain part number using the browser. The COM component accesses a file on an AS/400, providing availability information about the part. The Mobile:ObjectList control is then used to display the information in various ways and even allows WAP phones to dial the store where the part is available. Figures 3 and 4 show the application in action. These figures illustrate the differences between a MIT control's rendering on a WAP phone and an HTTP browser.
Figure 3: The WAP/WML emulator tool from Openwave Systems displays the results of a query using the example application.
Figure 4: The same results as in Figure 3 are rendered with Internet Explorer in HTML. (Click figure to enlarge.)
Using MIT, I created a single Web application that transparently supports both HTTP and WAP. Not only was I not required to discern the requesting client browser capabilities in the code, I also did not have to write a single line of WML. You may have noticed, however, that the HTML browser display in Figure 4 looks plain and slightly compressed. MIT controls are designed to be rendered on small displays such as Pocket PCs and mobile phones. Therefore, MIT controls produce compact content that is often embedded into a series of hyperlinked lists. These compact presentations suit WML browsers nicely, but they may be unreasonable for use in standard Web browsers. In fact, the MIT controls don't directly address many common Web page display elements, such as HTML tables, probably because tables can't be adequately formatted on mobile devices. MIT does support certain advanced formatting features not used in this simple application, such as stylesheets, to allow page designers to influence rendering on particular platforms.
MIT is an excellent tool for developers who need to create compact wireless Web applications quickly using the rich set of .NET classes and existing components.
Microsoft has done the heavy lifting to support WAP and HTTP simultaneously, allowing the programmer to concentrate on the application. Although Microsoft has not committed to new wireless applications protocols, it seems reasonable that it could easily extend MIT to new wireless platforms in the future.
Walter Goodwin is a software engineer at Amalgamated Software of North America (ASNA) in San Antonio, Texas, where he currently develops distributed systems software for enterprise platform developers. You can reach Walter at
References and Related Materials
- ASNA Visual RPG 3.1 download page: http://www.asna.com/avr_download.asp
- Microsoft Mobile Web Forms: http://msdn.microsoft.com/vstudio/nextgen/Technology/mobilewebforms.asp
- Microsoft .NET: http://msdn.microsoft.com/net/default.asp
- Openwave.com SDK 3.2 for WML: http://developer.openwave.com/download/index.html
Sidebar: Developing with Mobile Internet Toolkit
To get started with MIT and the general .NET Framework, you must be running Windows NT (with Service Pack 6a), Windows 2000 (with Service Pack 2), or Windows XP Professional. Before loading MIT, the .NET Framework Software Development Kit (SDK) should be installed. The .NET Framework includes ASP.NET, the XML classes, and all the general .NET Framework classes. You can download the .NET Framework SDK from the Microsoft Developer Network Web site, but be aware that the download is currently 131 MB. The Framework SDK is also available bundled with Microsoft's most recent IDE product, Visual Studio .NET. None of the code in the sample application was created with Visual Studio .NET, but it does contain many new tools, such as the Web Forms Designer, helpful for creating ASP.NET applications.
After the Framework has been installed, the MIT can be installed. MIT is a much smaller download (see References and Related Materials). Once installed, the MIT documentation page can be viewed with Internet Explorer (the document is named StartHere.htm, and it should be in the directory where MIT was installed).
When developing ASP.NET applications, note that ASP.NET files have the .aspx extension to distinguish the files from traditional ASP pages. The provided sample application has one ASP.NET file, PartSearch.aspx, containing the control templates and script code. This simple text file can be viewed with any text editor. The file should be installed into an Internet Information Server virtual directory, so that the file is accessible to a Web browser. For example, you should be able to access the file at http://localhost/locator/PartsSearch.aspx, where localhost is your machine name, and locator is the virtual directory containing the file.
PartsSearch.aspx is divided into three sections similar to the short examples of Figures 1 and 2: a header with <% %> page directives, a
BLOG COMMENTS POWERED BY DISQUS
LATEST COMMENTS
MC Press Online