5,695,118 members and growing! (14,842 online)
Email Password   helpLost your password?
General Programming » Internet / Network » General     Intermediate

Create WAP Push SMS Messages

By Adam Bird

How to generate a WAP Push SMS message for sending content to mobile phones.
C#Windows, .NET, .NET 1.0, .NET 1.1, Win2K, WinXP, Win2003VS.NET2003, Visual Studio, Dev

Posted: 9 Jun 2004
Updated: 25 Jul 2004
Views: 172,768
Bookmarked: 69 times
Announcements
Loading...



Search    
Advanced Search
Sitemap
26 votes for this Article.
Popularity: 5.76 Rating: 4.07 out of 5
2 votes, 7.7%
1
0 votes, 0.0%
2
3 votes, 11.5%
3
6 votes, 23.1%
4
15 votes, 57.7%
5

Introduction

WAP Push SMS messages are widely used for pushing polyphonic ringtones and wallpaper images to mobile phones. However, as you will see, they also present a compelling method of directing people to WAP sites without visibility on the operator's WAP Portals.

This article presents a set of C# classes that generate an SMS message that instructs a mobile to browse to a given URL.

Instructing The Device

WAP Push messages can contain a number of different bodies all designed to accomplish slightly different outcomes. The one we are interested in is the Service Indication. This is an XML document (DTD here) that contains a URL for the handset to browse to. For example:

<si>
  <indication href="http://wap.yahoo.com/" action="signal-high">
    A WAP Push to the Yahoo site
  </indication
</si>

In the mobile world, bandwidth and reliable connections are at a premium, so the method for getting this message to a device needs to be reliable and compact. XML has many strengths, compactness however is not one of them. Step in SMS and WBXML.

SMS is a reliable (depending on the service provider) store and forward mechanism for sending messages to mobile devices. Its use is not limited to person to person communication. It drives voice mail alerts, phone configurations, MMS notifications, and a whole host of other features we expect from mobile networks. The problem is that it is restricted to 140 bytes of data.

WBXML is binary format of XML that allows for compact transmission, while still preserving the structure and content of XML documents. Devices have inbuilt knowledge of certain XML DTDs that they are able to parse and understand.

One way this compactness is achieved is by a Tag Code Space being reserved for each DTD. Instead of the full tag name being sent, just a byte value is used to indicate the presence and position of the Tag. The Tag Code Space for the Service Indication DTD is shown below:

Tag Byte Value
si 0x05
indication 0x06

Another method is to replace common attributes and known values with byte values. In the case of the action attribute of the indication tag, which gives an indication of what level of interruption the device should attempt on receipt of this message, these are:

Attribute Byte Value
action="signal-none" 0x05
action="signal-low" 0x06
action="signal-medium" 0x07
action="signal-high" 0x08
action="signal-delete" 0x09

Use of these methods allow the XML document to be compressed sufficiently for transmission by SMS to the target device. A full description of the Service Indication can be found at the WAP Forum section of the Open Mobile Alliance web site.

Pushing The Instruction

Now that the instruction in the form of a Service Indication has been encoded, the data needs to be packaged into an SMS message. This requires two additional protocol layers to be wrapped around the instruction in order that it is read correctly by the recipient device.

The first layer is the WSP (Wireless Session Protocol). This is analogous to HTTP in the wired world, where a series of headers describe the content that is contained. As with the WBXML encoded Service Indication, these are actually transported as well known byte values in order to preserve bandwidth. The headers used in the WAP Push message are:

  • CONTENT-TYPE
  • CONTENT-LENGTH
  • APPLICATION-TYPE

Finally, the WDP (Wireless Datagram Protocol). For those of you who are familiar with sending Smart Messages to Nokia phones like VCard, Ringtones, Operator Logos, etc., this is the UDH (User Data Header). This contains an information element that describes the destination port on the mobile phone. This is used by the phone to decide which application it should fire up on receipt of this message. In our case, the WAP Browser.

Once all the layers are in place, you now have a series of bytes that have to be submitted to the mobile phone.

Using the code

The core classes comprise a ServiceIndication which is responsible for creating the content of the push; and PushMessage which is responsible for generating the complete message by wrapping the additional protocol layers. The classes WBXML, WSP, and WDP are holders for constants and statistics relating to the different protocol layers. The following code demonstrates how the body is generated:

string href = "http://wap.yahoo.com";
string text = "A WAP Push to the Yahoo site";

PushMessage message = new PushMessage(href, text);
HexDecoder decoder = new HexDecoder();

string body = new string(decoder.GetChars(message.GetSMSBytes()));

I have included a HexDecoder class we use internally for converting a byte array into Hex string.

Once the message body has been created, it's a simple process to send the message using a mobile phone connected to the PC's serial port, or an SMS Web Service such as this.

Points of Interest

The great thing about sending these kinds of messages to mobile phones is that they ignore them if they don't understand them. It makes debugging a nightmare.

I started with the Service Indication specification on the OMA web site but discovered that the handsets out there are not as up-to-date. In order to get this to work, I had to drop the creation and expiry attributes as well as drop the version number to 1.1.

The ServiceIndication class encodes itself to WBXML in a fairly procedural way. Tempted as I was to write a generic WBXML encoder, XP teaches us that simple is good ;).

The content length byte value in the WSP header has the high byte set, which suggests that the content is restricted to 128 bytes. This makes sense given the 140 bytes available, if anyone can clarify the position on this, I would appreciate it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Adam Bird


Managing Director of Esendex the SMS service provider, whose life is better because of XP and .NET.


Occupation: CEO
Company: Esendex
Location: United Kingdom United Kingdom

Other popular Internet / Network articles:

Article Top
Sign Up to vote for this article
You must Sign In to use this message board.
FAQ FAQ Noise ToleranceSearch Search Messages 
 Layout  Per page   
 Msgs 1 to 25 of 92 (Total in Forum: 92) (Refresh)FirstPrevNext
GeneralThe planet of mobilememberrony4u5:29 27 Jul '08  
GeneralWAP teletextmemberzmrcic4:07 7 Aug '07  
GeneralRe: WAP teletextmemberAdam Bird0:40 9 Aug '07  
GeneralRe: WAP teletextmembertouchring22:12 16 Oct '07  
QuestionHREF and SID not set.membermurphy score7:43 27 Jun '07  
AnswerRe: HREF and SID not set.memberAdam Bird18:23 22 Jul '07  
GeneralVery Nice Article!!!!!!!memberguroo100019:28 11 Jun '07  
GeneralRe: Very Nice Article!!!!!!!memberAdam Bird18:23 22 Jul '07  
GeneralSoftware demo showing application of WAP Push technology.membertouchring23:42 5 Apr '07  
GeneralRe: Software demo showing application of WAP Push technology.membertouchring23:55 5 Apr '07  
GeneralRe: Software demo showing application of WAP Push technology.memberAdam Bird5:44 6 Apr '07  
GeneralRe: Software demo showing application of WAP Push technology.membertouchring8:37 16 Oct '07  
GeneralWAP Pushmembershibby!5:01 10 Feb '07  
QuestionWap PUSH SI Message for Windows Mobilemembergouravjain1235:30 20 Sep '06  
AnswerRe: Wap PUSH SI Message for Windows Mobilemembersemljola23:39 20 May '07  
GeneralRe: Wap PUSH SI Message for Windows MobilememberAdam Bird18:33 22 Jul '07  
QuestionNotification SMS to Mobile Phonememberkumar1434:10 31 Aug '06  
AnswerRe: Notification SMS to Mobile Phonememberliaowg19:10 29 Aug '07  
QuestionWAP Message to activate Mobile application on mobile [modified]memberSomnath_Mali1:17 25 Jul '06  
AnswerRe: WAP Message to activate Mobile application on mobilememberbusinesms19:39 18 Aug '06  
GeneralYour SMS Message Using E MailmemberKapil Pershad14:52 22 May '06  
GeneralRe: Your SMS Message Using E Mailmemberbusinesms19:42 18 Aug '06  
GeneralRe: Your SMS Message Using E Mailmemberxaml.net3:29 13 Jan '07  
Questionhow to make a site wap pushmemberrane778:02 20 Apr '06  
NewsTo carry out a site wap pushmemberrane778:01 20 Apr '06  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 25 Jul 2004
Editor: Nishant Sivakumar
Copyright 2004 by Adam Bird
Everything else Copyright © CodeProject, 1999-2008
Web19 | Advertise on the Code Project