|By Charlie Arehart||
|August 23, 2000 12:00 AM EDT||
It's fun developing wireless applications in ColdFusion, but if you don't solve several key challenges it'll be more painful than pleasant.
In this second part of a series, I'll focus on some common problems encountered by CF/WML developers.
In the last issue the focus was on getting you started: an introduction to WAP (the Wireless Access Protocol), the early state of wireless programming, how to get a simulator to begin testing code, resources for learning more about WAP and the markup language for WAP phones, WML (Wireless Markup Language).
I intentionally didn't focus on WML itself or on the details of the WAP architecture. These matters are best left to the many SDK documents, Web sites and the growing number of books on the subject.
In this issue I'll focus on matters not covered by those resources: the problems you'll typically encounter when getting started with wireless programming in conjunction with ColdFusion. There are indeed many challenges that would affect any WML developer. I'll touch on a couple of them, but the real focus is on the CF-specific challenges, as well as some tips and tricks for getting things to work when trouble strikes.
The Key to Doing WML in CF
Before discussing the common challenges, I ought to at least give you a bit of sample code to begin with in case this is your first time reading about WML. As mentioned in the last article, I don't want to repeat too much of what was covered by Ben Forta's intro to WML in his December 1999 article, "No Strings Attached" (Vol. 1, issue 6). Please see that for more introductory WML.
The bottom line is that all you need is a properly formatted CFCONTENT tag to indicate to the browser that the code you're building is WML rather than HTML (ColdFusion's default). This sets the MIME type of the page you're creating. Simply include this at the top of your program:
<CFCONTENT TYPE="text/vnd.wap.wml">That's not quite all you need. There's a set of basic "prologue" statements that must be specified at the top of any WML page, so the more complete definition of the beginning of a CF/WML page, as offered in a simple "Hello World" example, is:
<CFCONTENT TYPE="text/vnd.wap.wml"><?xml version="1.0"?>Notice that we've put the first two lines of code on the same line. Many WML developers have found that the ?xml declaration line should be coded without any carriage returns preceding it.
<!DOCTYPE wml PUBLIC"-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">
From here you can use any CF code to generate any WML as needed by your application. Again, see other more general-interest WML resources for more about the WML you can use. And you can do this in any version of CF. This leads to a natural question often asked by new CF/WML developers: What version of ColdFusion allows WML programming?
When people notice that Allaire has highlighted new WML support in 4.5, they get the impression that WML can only be done in 4.5 of CF Server. In fact, the new support is really just extensions to CF Studio and HomeSite to support creating, editing and getting help on WML tags, and a new page wizard. We'll review those in a later article.
Any version of ColdFusion (Server and Studio) can support WML programming if you're coding the tags by hand, since all you need is that CFCONTENT tag at the top of the page.
The Inevitable Errors You'll Encounter
If you try this sample code, or when you begin doing more substantial code, you'll inevitably encounter errors. The challenge is determining if it's a CF error or a WML error, and even then what works in one phone may fail in another due to the incompatibilities of phones supporting WML in different ways (which is beyond the scope of this article). But there are some simple issues we can deal with.
Viewing the Code in the Right Browser
First of all, you can't expect to run the preceding code sample from within a browser like IE or Netscape (at least not the current versions). With the CFCONTENT tag in place, you can view the output of the page only in a browser that supports WML (phones or phone simulators, as discussed in the last article). If you try to view it in a normal browser, you'll likely receive a prompt to save the file being sent, since the browser doesn't know what to do with a file of the MIME type specified in the CFCONTENT tag.
Dealing with "Invalid Content" or "Syntax Errors"
Even when viewed on a real phone (or simulator), you'll encounter errors in your first forays into WML. There are a few things to keep in mind.
First, WML is case-sensitive. You must use lowercase for WML tags and attributes. Also, WML follows the rules of XML programming, so all tags must have a closing tag. Even a <p> tag must have a closing </p>, unlike in HTML, and tags like <br>, which have no closing tag, must be written as <br/>.
Note that you can't send HTML tags to a WML browser. (Well, that's not entirely true. Some WAP gateways can convert HTML to WML, but that's not universal and shouldn't be relied on.) If you send HTML to WML browsers, they'll generally "choke" on it. So be careful don't intermix HTML and WML. You really need to find some WML resources to learn more. For all their similarity, there are many significant differences between HTML and WML programming, and they're more than just differences in tag names.
Other problems could arise if you have an error in your CF code (causing CF to display an error message), or if you have server-side debugging information turned on, both of which generate HTML, as we'll discuss next.
Turn Off Server-Side Debugging
ColdFusion's HTML heritage can really get in the way when doing WML programming. When debugging is turned on in the Administrator, you normally see the debugging info at the bottom of any CF page. But that information is sent in HTML formatting to the browser, which is fine in a normal browser, but it's death to most WML browsers since they can't read HTML.
You don't need to turn off debugging in the Administrator. As of ColdFusion release 4, you have the option to turn off debugging with the following line of code:
<CFSETTING SHOWDEBUGOUTPUT="no">This will disable debugging until you turn it on again or until the currently running template ends. If you're running a release of ColdFusion prior to release 4, it's probably best to just turn off server-side debugging.
Why Can't I See ColdFusion Error Messages?
On a related matter, the same problem of CF's HTML heritage has to do with error message handling. When you get an error in CF, you normally see the CF error message display indicating the error and the page and line number of the code in error. But that error is also sent in HTML formatting to the browser, which chokes the WML browser.
This would seem a real dilemma. You can't see the error because the phone doesn't recognize it as valid WML. So how are you supposed to deal with it? Well, fortunately, Allaire has put in place error-handling components to improve the ability of the developer to control the error message display to the user.
You might think that CFERROR, and its ability to create a specially formatted error page, might come to the rescue. Unfortunately, the two older forms of CFERROR pages (type="request" and type="validation") send pure HTML (and an HTML MIME type), which you can't override. Since you can't put any CF tags on those error pages, you can't even add a CFCONTENT.
(This also means, of course, that you can't use CF's hidden field validation to do server-side form validation. The validation error page that it offers is also pure HTML and you can't override it.)
Perhaps Allaire will offer a solution to these dilemmas in the future. For now, if you have release 4.5, you can in many cases at least solve some of the first problem seeing CF error messages by taking advantage of the new CFERROR type="exception". This transfers control when an error occurs to a page that is allowed to do CF tags (an incredibly valuable new feature in and of itself), including a CFCONTENT tag. You can then format the error for display to the WML browser.
Formatting the Error Message Itself
You're not quite done, though. The CF error message itself, offered inside such a CFERROR page as the variable CFERROR.Diagnostics, will usually be HTML-formatted. This was fine when sending it for display to an HTML browser, but again it's a problem in WML. Fortunately, you can solve it by using a CF function to convert the HTML tags in the message into their corresponding display codes, such as &gt; for > and &lt; for <.
Allaire offers two solutions for this. In 4.5 there's an XmlFormat() function for just this purpose. In older releases you can use HtmlEditFormat(). It's not the perfect solution, as it'll simply cause any HTML tags in the error message to be displayed to the screen, but it's easier than trying to strip out the HTML tags.
This approach can also be used to format error messages displayed in a CFCATCH (using the "cfcatch.detail" variable).
You may want to create an application.cfm that sets the CFSETTING to disable debugging output (on a release 4 or above server) and sets a CFERROR type="exception" (on a release 4.5 or above server) to point to a template that can format the error message in WML.
Keep in mind that none of this CF error handling will help if the error in your page is due to badly formed WML. In this case you'd do well to have a simulator that allows you to see the actual WML being sent to the browser (most real phones won't provide access to that information).
Form Processing Works in Simulator, Fails in Real Phone
This is another thorny problem, and it's not generally CF-specific. Some background will help. When you test code in most simulators, you may be using a form of communication between the simulator and the Web server that's often called "http direct". There is direct communication between the simulator and the server.
This is fine, but real phones use a form of communication that goes from the phone to a gateway (usually within the phone company provider) that then communicates to the Web server on the phone user's behalf. (It acts as both a proxy and a translator, since what's really sent to real phones is an encoded form of WML to minimize data traffic.)
The problem with this scenario is that code that works fine in the "http direct" mode may fail when run on a real phone or in the simulator's gateway mode.
A perfect example of this is "form processing" by way of the "post" method. If the example in Listing 1 is submitted on a simulator, it will work, but on a real phone it may fail.
I don't have room here to explain the unique differences of form processing in WML versus HTML, but the example shows many of the significant features. Note that there's no "form" tag per se, and that the form data is gathered in one place (the input tag), stored in a variable on the phone ("stock") and passed to the server in yet another tag (<go>) when the user presses the "accept" button or equivalent. Very different from HTML! But note the powerful new formatting possibilities in the <input> tag. This allows only up to four alphanumeric characters.
The problem occurs when the page itself is submitted with method="post". In testing on a simulator in HTTP direct mode, this code works fine. In a real phone, however, which goes through a gateway, it will fail to submit. In the Phone.com simulator, using the "up.link" mode to go through a gateway, it fails with an error "500:internal server error". It seems the gateway is simply unable to make a "post" method call to the server.
And it doesn't seem to be restricted to CF Server (I tested the problem against an ASP program and got the same error). It may be restricted to Phone.com gateways, though I've heard it happened to users of Nokia phones and simulators.
The short-term solution is to change the method to "get". ColdFusion will receive the variables as "url." variables (in the example above, the "url.symbol"). Unlike in HTML browsers, this doesn't have the same problem of showing the user the form variables on the URL of the action page since phone users don't see the URLs of sites they're visiting (currently).
There is the security risk that on an SSL-enabled connection (called WTLS in the WAP world) the data passed on the URL isn't encrypted, so this isn't a solution that will work when passing userids and passwords, or credit cards if the goal is to encrypt that data. But that, too, is beyond the scope of this article.
That's All for Now
That's all the time (or rather, room) we have this month. Upcoming articles in this series will cover some other challenges (and solutions) regarding wireless development, such as doing browser detection to serve both HTML and WML browsers, handling sessions in an environment in which cookies aren't always supported, doing CFLOCATION (you have to use Web server root-relative paths, even to send to a file in the same directory), what to do when CFCONTENT simply doesn't work in your CF server, processing multivalued form field submissions, sending notifications and pushing messages to the phone (using COM objects), and the support in Studio for WML.
You can learn about WML and generic challenges as well as more about these CF challenges in the recently released book Professional WAP (Wrox Press). I have a chapter in the book on CF/WML programming. Other WML/WAP books will soon be in the market as well.
“We're a global managed hosting provider. Our core customer set is a U.S.-based customer that is looking to go global,” explained Adam Rogers, Managing Director at ANEXIA, in this SYS-CON.tv interview at 18th Cloud Expo, held June 7-9, 2016, at the Javits Center in New York City, NY.
Feb. 24, 2017 07:30 AM EST Reads: 1,835
Data is the fuel that drives the machine learning algorithmic engines and ultimately provides the business value. In his session at Cloud Expo, Ed Featherston, a director and senior enterprise architect at Collaborative Consulting, discussed the key considerations around quality, volume, timeliness, and pedigree that must be dealt with in order to properly fuel that engine.
Feb. 24, 2017 06:15 AM EST Reads: 5,459
Data is the fuel that drives the machine learning algorithmic engines and ultimately provides the business value. In his session at 20th Cloud Expo, Ed Featherston, director/senior enterprise architect at Collaborative Consulting, will discuss the key considerations around quality, volume, timeliness, and pedigree that must be dealt with in order to properly fuel that engine.
Feb. 24, 2017 04:00 AM EST Reads: 3,802
SYS-CON Events announced today that DatacenterDynamics has been named “Media Sponsor” of SYS-CON's 18th International Cloud Expo, which will take place on June 7–9, 2016, at the Javits Center in New York City, NY. DatacenterDynamics is a brand of DCD Group, a global B2B media and publishing company that develops products to help senior professionals in the world's most ICT dependent organizations make risk-based infrastructure and capacity decisions.
Feb. 24, 2017 03:00 AM EST Reads: 1,827
"Matrix is an ambitious open standard and implementation that's set up to break down the fragmentation problems that exist in IP messaging and VoIP communication," explained John Woolf, Technical Evangelist at Matrix, in this SYS-CON.tv interview at @ThingsExpo, held Nov 4–6, 2014, at the Santa Clara Convention Center in Santa Clara, CA.
Feb. 24, 2017 02:15 AM EST Reads: 13,206
Growth hacking is common for startups to make unheard-of progress in building their business. Career Hacks can help Geek Girls and those who support them (yes, that's you too, Dad!) to excel in this typically male-dominated world. Get ready to learn the facts: Is there a bias against women in the tech / developer communities? Why are women 50% of the workforce, but hold only 24% of the STEM or IT positions? Some beginnings of what to do about it! In her Day 2 Keynote at 17th Cloud Expo, Sandy Ca...
Feb. 24, 2017 01:45 AM EST Reads: 9,545
IoT is at the core or many Digital Transformation initiatives with the goal of re-inventing a company's business model. We all agree that collecting relevant IoT data will result in massive amounts of data needing to be stored. However, with the rapid development of IoT devices and ongoing business model transformation, we are not able to predict the volume and growth of IoT data. And with the lack of IoT history, traditional methods of IT and infrastructure planning based on the past do not app...
Feb. 24, 2017 01:00 AM EST Reads: 1,903
WebRTC services have already permeated corporate communications in the form of videoconferencing solutions. However, WebRTC has the potential of going beyond and catalyzing a new class of services providing more than calls with capabilities such as mass-scale real-time media broadcasting, enriched and augmented video, person-to-machine and machine-to-machine communications. In his session at @ThingsExpo, Luis Lopez, CEO of Kurento, introduced the technologies required for implementing these idea...
Feb. 23, 2017 11:30 PM EST Reads: 6,311
Why do your mobile transformations need to happen today? Mobile is the strategy that enterprise transformation centers on to drive customer engagement. In his general session at @ThingsExpo, Roger Woods, Director, Mobile Product & Strategy – Adobe Marketing Cloud, covered key IoT and mobile trends that are forcing mobile transformation, key components of a solid mobile strategy and explored how brands are effectively driving mobile change throughout the enterprise.
Feb. 23, 2017 11:00 PM EST Reads: 7,025
Apache Hadoop is emerging as a distributed platform for handling large and fast incoming streams of data. Predictive maintenance, supply chain optimization, and Internet-of-Things analysis are examples where Hadoop provides the scalable storage, processing, and analytics platform to gain meaningful insights from granular data that is typically only valuable from a large-scale, aggregate view. One architecture useful for capturing and analyzing streaming data is the Lambda Architecture, represent...
Feb. 23, 2017 10:00 PM EST Reads: 4,622
SYS-CON Events announced today that delaPlex will exhibit at SYS-CON's @CloudExpo, which will take place on June 6-8, 2017, at the Javits Center in New York City, NY. delaPlex pioneered Software Development as a Service (SDaaS), which provides scalable resources to build, test, and deploy software. It’s a fast and more reliable way to develop a new product or expand your in-house team.
Feb. 23, 2017 09:15 PM EST Reads: 1,539
The explosion of new web/cloud/IoT-based applications and the data they generate are transforming our world right before our eyes. In this rush to adopt these new technologies, organizations are often ignoring fundamental questions concerning who owns the data and failing to ask for permission to conduct invasive surveillance of their customers. Organizations that are not transparent about how their systems gather data telemetry without offering shared data ownership risk product rejection, regu...
Feb. 23, 2017 08:45 PM EST Reads: 1,310
With major technology companies and startups seriously embracing IoT strategies, now is the perfect time to attend @ThingsExpo 2016 in New York. Learn what is going on, contribute to the discussions, and ensure that your enterprise is as "IoT-Ready" as it can be! Internet of @ThingsExpo, taking place June 6-8, 2017, at the Javits Center in New York City, New York, is co-located with 20th Cloud Expo and will feature technical sessions from a rock star conference faculty and the leading industry p...
Feb. 23, 2017 08:30 PM EST Reads: 1,466
The Internet of Things will challenge the status quo of how IT and development organizations operate. Or will it? Certainly the fog layer of IoT requires special insights about data ontology, security and transactional integrity. But the developmental challenges are the same: People, Process and Platform and how we integrate our thinking to solve complicated problems. In his session at 19th Cloud Expo, Craig Sproule, CEO of Metavine, demonstrated how to move beyond today's coding paradigm and sh...
Feb. 23, 2017 07:45 PM EST Reads: 3,411
SYS-CON Events announced today that IoT Now has been named “Media Sponsor” of SYS-CON's 20th International Cloud Expo, which will take place on June 6–8, 2017, at the Javits Center in New York City, NY. IoT Now explores the evolving opportunities and challenges facing CSPs, and it passes on some lessons learned from those who have taken the first steps in next-gen IoT services.
Feb. 23, 2017 06:45 PM EST Reads: 1,466
As organizations realize the scope of the Internet of Things, gaining key insights from Big Data, through the use of advanced analytics, becomes crucial. However, IoT also creates the need for petabyte scale storage of data from millions of devices. A new type of Storage is required which seamlessly integrates robust data analytics with massive scale. These storage systems will act as “smart systems” provide in-place analytics that speed discovery and enable businesses to quickly derive meaningf...
Feb. 23, 2017 06:30 PM EST Reads: 6,306
SYS-CON Events announced today that WineSOFT will exhibit at SYS-CON's 20th International Cloud Expo®, which will take place on June 6-8, 2017, at the Javits Center in New York City, NY. Based in Seoul and Irvine, WineSOFT is an innovative software house focusing on internet infrastructure solutions. The venture started as a bootstrap start-up in 2010 by focusing on making the internet faster and more powerful. WineSOFT’s knowledge is based on the expertise of TCP/IP, VPN, SSL, peer-to-peer, mob...
Feb. 23, 2017 06:30 PM EST Reads: 1,732
SYS-CON Media announced today that @WebRTCSummit Blog, the largest WebRTC resource in the world, has been launched. @WebRTCSummit Blog offers top articles, news stories, and blog posts from the world's well-known experts and guarantees better exposure for its authors than any other publication. @WebRTCSummit Blog can be bookmarked ▸ Here @WebRTCSummit conference site can be bookmarked ▸ Here
Feb. 23, 2017 06:00 PM EST Reads: 13,077
The Internet of Things can drive efficiency for airlines and airports. In their session at @ThingsExpo, Shyam Varan Nath, Principal Architect with GE, and Sudip Majumder, senior director of development at Oracle, discussed the technical details of the connected airline baggage and related social media solutions. These IoT applications will enhance travelers' journey experience and drive efficiency for the airlines and the airports.
Feb. 23, 2017 06:00 PM EST Reads: 1,526
In his keynote at @ThingsExpo, Chris Matthieu, Director of IoT Engineering at Citrix and co-founder and CTO of Octoblu, focused on building an IoT platform and company. He provided a behind-the-scenes look at Octoblu’s platform, business, and pivots along the way (including the Citrix acquisition of Octoblu).
Feb. 23, 2017 05:45 PM EST Reads: 1,240