Click here to Skip to main content
11,706,323 members (48,172 online)
Click here to Skip to main content

Create WAP Push SMS Messages

, 25 Jul 2004 351.7K 2.1K 90
Rate this:
Please Sign up or sign in to vote.
How to generate a WAP Push SMS message for sending content to mobile phones.

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 Wink | ;) .

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

Share

About the Author

Adam Bird
Chief Technology Officer Esendex
United Kingdom United Kingdom
Co-founder and CTO of Esendex the SMS service provider, whose life is better because of XP and .NET.

You may also be interested in...

Comments and Discussions

 
GeneralMen Pin
Diwesh kumar4-Jan-12 4:46
memberDiwesh kumar4-Jan-12 4:46 
General00923242024500 Pin
nomi shani30-May-11 19:48
membernomi shani30-May-11 19:48 
General03242024500 Pin
nomi shani30-May-11 19:41
membernomi shani30-May-11 19:41 
GeneralSend wap push message with GSM modem Pin
noah lubko21-Mar-11 5:06
membernoah lubko21-Mar-11 5:06 
Generalsms voting Pin
wire2airindia26-Jun-10 6:42
memberwire2airindia26-Jun-10 6:42 
Newssms gateway , mobile marketing, sms Pin
wire2airindia10-Jun-10 2:56
memberwire2airindia10-Jun-10 2:56 
Questionmath.floor??!? Pin
DutchRhino23-Nov-09 3:09
memberDutchRhino23-Nov-09 3:09 
AnswerRe: math.floor??!? Pin
Adam Bird24-Nov-09 22:12
memberAdam Bird24-Nov-09 22:12 
GeneralRe: math.floor??!? Pin
DutchRhino24-Nov-09 22:24
memberDutchRhino24-Nov-09 22:24 
GeneralRing tones download from Asp.Net web site Pin
miltash27-Sep-09 22:08
membermiltash27-Sep-09 22:08 
GeneralRe: Ring tones download from Asp.Net web site Pin
Adam Bird28-Sep-09 22:21
memberAdam Bird28-Sep-09 22:21 
GeneralRe: Ring tones download from Asp.Net web site Pin
dcornel_200730-Oct-09 13:35
memberdcornel_200730-Oct-09 13:35 
QuestionMulti part message Pin
kiwiju1-Jul-09 0:32
memberkiwiju1-Jul-09 0:32 
AnswerRe: Multi part message Pin
Mtidings7-Jul-09 14:20
memberMtidings7-Jul-09 14:20 
GeneralRe: Multi part message Pin
Adam Bird7-Jul-09 22:27
memberAdam Bird7-Jul-09 22:27 
Generalweb service used [modified] Pin
Justin Pravin12-May-09 0:51
memberJustin Pravin12-May-09 0:51 
GeneralRe: web service used Pin
Adam Bird26-Jun-09 0:05
memberAdam Bird26-Jun-09 0:05 
GeneralThanks Pin
satalaj24-Feb-09 19:16
membersatalaj24-Feb-09 19:16 
GeneralThe planet of mobile Pin
rony4u27-Jul-08 4:29
memberrony4u27-Jul-08 4:29 
GeneralWAP teletext Pin
zmrcic7-Aug-07 3:07
memberzmrcic7-Aug-07 3:07 
GeneralRe: WAP teletext Pin
Adam Bird8-Aug-07 23:40
memberAdam Bird8-Aug-07 23:40 
GeneralRe: WAP teletext Pin
touchring16-Oct-07 21:12
membertouchring16-Oct-07 21:12 
QuestionHREF and SID not set. Pin
murphy score27-Jun-07 6:43
membermurphy score27-Jun-07 6:43 
AnswerRe: HREF and SID not set. Pin
Adam Bird22-Jul-07 17:23
memberAdam Bird22-Jul-07 17:23 
GeneralVery Nice Article!!!!!!! Pin
guroo100011-Jun-07 18:28
memberguroo100011-Jun-07 18:28 
GeneralRe: Very Nice Article!!!!!!! Pin
Adam Bird22-Jul-07 17:23
memberAdam Bird22-Jul-07 17:23 
GeneralSoftware demo showing application of WAP Push technology. Pin
touchring5-Apr-07 22:42
membertouchring5-Apr-07 22:42 
GeneralRe: Software demo showing application of WAP Push technology. Pin
touchring5-Apr-07 22:55
membertouchring5-Apr-07 22:55 
GeneralRe: Software demo showing application of WAP Push technology. Pin
Adam Bird6-Apr-07 4:44
memberAdam Bird6-Apr-07 4:44 
GeneralRe: Software demo showing application of WAP Push technology. Pin
touchring16-Oct-07 7:37
membertouchring16-Oct-07 7:37 
GeneralRe: Software demo showing application of WAP Push technology. Pin
carolynjoseph2-Jun-10 8:41
membercarolynjoseph2-Jun-10 8:41 
GeneralRe: Software demo showing application of WAP Push technology. Pin
justinbryan8-Jun-10 6:56
memberjustinbryan8-Jun-10 6:56 
GeneralRe: Software demo showing application of WAP Push technology. Pin
justinbryan5-Jul-10 3:36
memberjustinbryan5-Jul-10 3:36 
GeneralRe: Software demo showing application of WAP Push technology. Pin
wire2airindia9-Jun-10 2:29
memberwire2airindia9-Jun-10 2:29 
GeneralRe: Software demo showing application of WAP Push technology. Pin
wire2airindia21-Jun-10 9:34
memberwire2airindia21-Jun-10 9:34 
GeneralWAP Push Pin
shibby!10-Feb-07 4:01
membershibby!10-Feb-07 4:01 
QuestionWap PUSH SI Message for Windows Mobile Pin
gouravjain12320-Sep-06 4:30
membergouravjain12320-Sep-06 4:30 
AnswerRe: Wap PUSH SI Message for Windows Mobile Pin
semljola20-May-07 22:39
membersemljola20-May-07 22:39 
GeneralRe: Wap PUSH SI Message for Windows Mobile Pin
Adam Bird22-Jul-07 17:33
memberAdam Bird22-Jul-07 17:33 
QuestionNotification SMS to Mobile Phone Pin
kumar14331-Aug-06 3:10
memberkumar14331-Aug-06 3:10 
AnswerRe: Notification SMS to Mobile Phone Pin
liaowg29-Aug-07 18:10
memberliaowg29-Aug-07 18:10 
QuestionWAP Message to activate Mobile application on mobile [modified] Pin
Somnath_Mali25-Jul-06 0:17
memberSomnath_Mali25-Jul-06 0:17 
AnswerRe: WAP Message to activate Mobile application on mobile Pin
businesms18-Aug-06 18:39
memberbusinesms18-Aug-06 18:39 
GeneralYour SMS Message Using E Mail Pin
Kapil Pershad22-May-06 13:52
memberKapil Pershad22-May-06 13:52 
GeneralRe: Your SMS Message Using E Mail Pin
businesms18-Aug-06 18:42
memberbusinesms18-Aug-06 18:42 
GeneralRe: Your SMS Message Using E Mail Pin
xaml.net13-Jan-07 2:29
memberxaml.net13-Jan-07 2:29 
Questionhow to make a site wap push Pin
rane7720-Apr-06 7:02
memberrane7720-Apr-06 7:02 
NewsTo carry out a site wap push Pin
rane7720-Apr-06 7:01
memberrane7720-Apr-06 7:01 
GeneralWSP Headers Pin
Scott Harper11-Apr-06 11:06
memberScott Harper11-Apr-06 11:06 
QuestionDoes SMS Push-Pull require multithreading support? Pin
just_chill3-Mar-06 22:25
memberjust_chill3-Mar-06 22:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.150819.1 | Last Updated 26 Jul 2004
Article Copyright 2004 by Adam Bird
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid