Deliver
cellular messages with SMS - JavaWorld March 2001
Tutorial Details:
Deliver cellular messages with SMS
Deliver cellular messages with SMS
By: By Sonal Bansal and Gaurav Pal
SMS: A shortcut to providing information services to cell phones
he mobile communication device market is growing exponentially. A survey by Gartner Dataquest predicted that worldwide mobile phone sales will have totaled 412.7 million units in 2000, a 45.5 percent increase from 1999. (See Resources for a link to the survey.) This growth, coupled with the Internet's evolution into a Web of services, has fueled demand for Internet-enabled services that wireless devices -- particularly cell phones -- can readily access. Many technologies can be harnessed to provide value-added services over a cell phone, including Wireless Application Protocol (WAP) and Short Message Service (SMS).
Developed by the WAP Forum, WAP is a standard for providing Internet communications to wireless devices like cell phones, PDAs, and pagers. WAP was expected to be the predominant standard for providing ubiquitous mobile Internet access; however, several reports indicate that WAP is unlikely to succeed in the short- to medium-term. Because of insufficient infrastructural investments in gateways, WAP-enabled handsets did not coevolve to support this service. There are lingering performance concerns as well. In a survey conducted by the department of mass communications at Tamkang University (Taiwan), over 80 percent of WAP-enabled cell phone users expressed dissatisfaction with WAP. (See Resources .) The reasons cited included speed -- rather, lack of it -- expense, and lack of content. Those factors might lead to a dead-on-arrival situation with WAP, which directly affects application developers. It makes little sense to invest in a technology that might not survive.
SMS is a viable standard that offers a platform for delivering wireless information services. SMS cannot match WAP's wireless browsing capabilities, but it can meet the demand for point-to-point message-based services. SMS-enabled information services become even more attractive when you compare the large base of installed SMS-enabled cell phones to the paltry number of WAP-ready phones. According to a March 2000 report on internet.com -- "Companies Seek to Bridge 'WAP Gap,'" (see Resources for a link) -- over 400 million legacy (non-WAP-enabled) digital wireless phones are in use today.
Banking on SMS's productivity, we propose a server-side Java-based solution that provides information services to cell phones via SMS and Web form scraping.
What is SMS?
Developed in 1991, SMS is a globally accepted wireless service that enables the transmission of alphanumeric messages between mobile subscribers and external systems like email, paging, and voice mail systems.
With SMS, an active mobile handset can receive or submit a short message at any time, even if a voice or data call is in progress. SMS also guarantees delivery of the short message by the network. Temporary failures due to unavailable receiving stations are identified, and the short message is stored until the destination device becomes available.
Initial applications of SMS focused on eliminating alphanumeric pagers by permitting two-way general-purpose messaging and notification services, primarily for voice mail. As technology and networks evolved, a variety of services were introduced, including interactive banking, information services such as stock quotes, integration with Internet-based applications, and email, fax, and paging integration. In addition, integration with the Internet spurred the development of Web-based messaging and other interactive applications such as instant messaging, gaming, and chatting.
Here are a few reasons why SMS, not WAP, should be used for value-added services in the short- to medium-term:
Large number of legacy, i.e., non-WAP, phones
WAP's uncertain future
Lack of widespread WAP content (as of yet)
SMS is suitable for meeting major market needs
SMS can be used as a kind of push technology, meaning the user doesn't have to request delivery of information -- it can be automatically sent to her/him
Based on the projected demand for wireless services, wireless messaging and access to financial services appear to be predominant, dwarfing the need for browsing (WAP's core strength).
To harness SMS to deliver information to a cell phone, we propose using HTML forms available from major cell phone service providers to send messages to their subscribers. This helps us keep the solution simple and practical.
Web form scraping
A Web form is an HTML Webpage that submits information (such as user name, password, and so forth) to the server. Web form scraping is the act of interacting with an HTML Web form via a computer program. Most cell phone providers have HTML forms on their Websites, from which SMS messages can be sent to subscribers. Our solution will use this feature to deliver wireless content such as stock quotes without actually being connected to the wireless network.
Practical Java solution
We will demonstrate an application that you can use to push Web content to users' cell phones via SMS. Some common application scenarios are:
Stock trade confirmations/stock quotes
News
User-notification service Our two-part solution is composed of a Java servlet and an application that delivers stock quotes to the user's cell phone using SMS. You can also use it to easily deliver other services. The application fetches the stock information from well-known Websites and sends it to the user's cell phone. The user must first create a profile that details the stock symbols, frequency of updates, and other relevant information.
The application works as follows:
Using an HTML form, a Java servlet retrieves and stores the user's profile information. That information includes the following:
Unique ID -- email address, in this case
Cell phone provider
Cell phone number
Frequency of updates
Content preference -- stock symbols, in this case
A local text file stores the profile.
A console application, which might run in a separate JVM, takes care of the timing and dispatch. It retrieves the stock quotes from Yahoo Quotes and determines which users should be sent messages, based on their frequency preferences.
For every eligible user, the application passes the stock quotes to a handler, based on the user's cell phone provider.
The handler posts the data to an HTML form on the provider's Website, which offers a Web-to-SMS interface.
The application sleeps for an hour and returns to step 3.
The figure below illustrates the high-level flow. First, the user enters the profile via a desktop-based browser that communicates with the CellQuotes servlet. That servlet stores the profile in a simple flat file, which is then read by the TimeWorker application. Based on the profile settings, the TimeWorker application retrieves the stock quotes from a datastream provider, e.g., http://quote.yahoo.com, and posts to the appropriate cell provider's HTML form. Then the data forwards to the appropriate cell phone via SMS.
Simplified scenario diagram
Solution architecture
Our solution uses the following classes:
( Note: you can download the entire source code from Resources .)
Profile.java encapsulates user-specific information
ProfileReader.java reads profiles from the flat file as Profile objects
ProfileWriter.java writes Profile objects to the flat file
Constants.java contains constants such as profile filename
CellQuotes.java is the servlet that provides the Web interface to our solution
TimeWorker.java is the behind-the-scenes application that takes care of actual dispatch
CellProvider.java is the interface that must be extended in order to add cellular service providers
CellProviderSelector.java is the factory that returns the appropriate CellProvider implementation
The other classes are merely helpers, so we'll concentrate on the CellQuotes servlet and the TimeWorker application, which share a common resource: the transaction file. The servlet writes profiles to the transaction file; the application reads new profiles from the file and adds them to the main store. Therefore, the transaction file needs to be synchronized. In a simplistic approach, we have designated a token lockFile . If the servlet finds that the lockFile exists, then it assumes the application is reading from the transaction file and waits its turn. If the application finds that the lockFile exists, then it assumes the servlet is writing to the transaction file and waits its turn. We have also provided a time-out functionality to avoid resource starvation and deadlock.
The code for the CellQuotes servlet is as follows:
public class CellQuotes extends HttpServlet
{
public void doGet(...) throws ServletException
{
// return HTML Form to user
// We do this by simply reading a local file and dumping it to the response stream
}
public void doPost(...) throws ServletException
{
// extract profile information from POST
// assume its already been validated by JavaScript on client
// save parameters as new Profile object
...
// Write the profile to disk
writeProfile(profile);
...
// clean up
...
}
private void writeProfile(Profile p)
{
// synchronize on some static object, so that multiple servlet instances don't corrupt profiles file
synchronized(obj)
{
// check for existence of LockFile
if(Constants.lockFile.exists())
{
// waiting and timeout code goes here
}
// Since access is available, create lockfile and write to transaction file
ProfileWriter pw = new ProfileWriter(Constants.transactionFile);
prw.writeProfile(p);
...
}
}
}
You might wonder why we completed synchronization in such a roundabout manner, using lockFile s, timeouts, and whatnot. Why not just synchronize on a common static object? Unfortunately, it's not that simple. Our approach accounts for the fact that the servlet and application might run in different JVMs (which is almost a given); that means
Read
Tutorial at: Click here to view the tutorial
Rate Tutorial: Deliver
cellular messages with SMS - JavaWorld March 2001
View Tutorial: Deliver
cellular messages with SMS - JavaWorld March 2001
Related
Tutorials:
XML messaging, Part
3
XML messaging, Part
3 |
Connect the
enterprise with the JCA, Part 1
Connect the
enterprise with the JCA, Part 1 |
Cut down on
logging errors with Jylog
Cut down on
logging errors with Jylog |
A birds-eye view of Web services
A birds-eye view of Web services |
Transaction and redelivery in JMS
Transaction and redelivery in JMS |
Master J2ME for live data
delivery
Master J2ME for live data
delivery |
Jabber away with instant
messaging
Jabber away with instant
messaging |
Manage users with
JMS
Manage users with
JMS |
Test email components in your software
Test email components in your software |
Develop state-of-the-art mobile
games
Develop state-of-the-art mobile
games |
SMS-Powered Applications
SMS-Powered Applications
Every business tries to get as close as it can to its customers. The aim is to keep customers up to date with company news, products or service updates, relevant information about their accounts, or to send them notifications for |
IberAgents
Introduction
IberAgents is a web application framework that enables the creation of SOAP-interoperable components in Java, with life cycle management and remote configuration. Development started in 2001; we now have a mature, solid open-source platform |
Develop MIDlets using the J2ME MIDP Development for NetBeans IDE 4.0
This release integrates with the J2ME Wireless Toolkit 2.2 to create a powerful environment for developing MIDP 2.0 applications. |
istory of Bioinformatics
istory of Bioinformatics
History of Bioinformatics
The Modern bioinformatics is can be classified into two broad categories, Bi ological Science and computational Science . Here is the data of hi storical events for both biology and computer |
Writing your First WAP Application.
Writing your First WAP Application.
Tutorial
Writing your First Application.
N ow it's time to mould your Internet Data for the entire Unwired World!
Our "Welcome to Unwired World" application will familiarize you with the WML code.
As |
What is WAP? Detailed discussion of WAP API with examples.
What is WAP? Detailed discussion of WAP API with examples.
Learn WAP in 60 minutes
W ireless Application Protocol or WAP for short, allows the developers to develop next generation web application for cellular devices. Through WAP enabled mobile |
WAP Toolkits Motorola - Mobile ADK 1.1 Nokia - WAP Toolkit
WAP Toolkits Motorola - Mobile ADK 1.1 Nokia - WAP Toolkit
Tutorial
WAP Toolkits
T o develop any WAP application you have to download software essential for development. Although you can write and test your codes through our site for learning |
Using image in WML We can use the
Using image in WML We can use the
Tutorial
Using image in WML
In this lesson we will write application that images. We can use the tag to display the image in our document. The image appears wherever tag is placed within the text. |
What is WAP? Wireless Application Protocol
What is WAP? Wireless Application Protocol
Tutorial
What is WAP?
W ireless Application Protocol or WAP for short is simply a protocol - a standerized way for delivering Internet data over wireless networks. Thus WAP links Wireless Network with |
Chat Transcript: Java Web Services Developer Pack (Java WSDP) 1.5
Learn about the exciting new web services features in the recently-released Java WSDP 1.5. |
|
|
|