Sending SMS WAP Bookmark messages using the ActiveXperts SMS and MMS Toolkit.

What is WAP Bookmark ?

WAP Bookmark can be used to send a location of a WAP site to a mobile phone. A WAP Bookmark is basically a specially encoded message which includes a link to a WAP or WWW address. WAP Bookmark is specified on top of WDP (WAP Datagram Protocol, resembled the UDP protocol in the Internet); as such, it can be delivered over any WDP-supported bearer, such as GPRS or SMS.

WAP Bookmark messages are encoded as XML. Because the XML format is not suitable for low bandwidth applications such as SMS, the messages are encoded using WBXML which stands for WAP Binary XML. When a message is encoded using this standard, common tags and attribute values are replaced with a single byte.

The full specification of this format van be found at www.w3.org.

Sample of a WAP Bookmark message in XML:

<?xml version="1.0"?>
<!DOCTYPE si PUBLIC "-//WAPFORUM//DTD SI 1.0//EN" "http://www.wapforum.org/DTD/si.dtd">
<CHARACTERISTIC-LIST>
<CHARACTERISTIC TYPE="BOOKMARK">
<PARM NAME="NAME" VALUE="yahoo"/>
<PARM NAME="URL" VALUE="http://wap.yahoo.com"/>
</CHARACTERISTIC>
</CHARACTERISTIC-LIST> 

The same WAP Bookmark message in WBXML (excluding the WSP header) :

0x45                  <CHARACTERISTIC-LIST>
0xC6                  <CHARACTERISTIC
0x7F                  TYPE="BOOKMARK" ( application/x-wap-prov.browser-bookmarks )
0x01                  >
0x87                  PARAM
0x15                  NAME="NAME"
0x11                  VALUE
0x03                  String value follows
0x57                  'W'
0x61                  'A'
0x70                  'P'
0x20                  ' '
0x42                  'B'
0x6F                  'o'
0x6F                  'o'
0x6B                  'k'
0x6D                  'm'
0x61                  'a'
0x72                  'r'
0x6b                  'k'
0x20                  ' '
0x4D                  'M'
0x65                  'e'
0x73                  's'
0x73                  's'
0x61                  'a'
0x67                  'g'
0x65                  'e' 
0x00                  end of string value
0x01                  </PARAM>
0x08                  <PARAM?
0x17                  NAME="URL"
0x11                  VALUE
0x03                  String value follows
0x68                  'h'
0x74                  't'
0x74                  't'
0x70                  'p'
0x3A                  ':'
0x2F                  '/'
0x2F                  '/'
0x77                  'w'
0x61                  'a'
0x70                  'p'
0x2E                  '.'
0x79                  'y'
0x61                  'a'
0x68                  'h'
0x6F                  'o'
0x6F                  'o'
0x2E                  '.'
0x63                  'c'
0x6F                  'o'
ox6D                  'm'
0x00                  end of string value
0x01                  </PARAM>
0x01                  </CHARACTERISTIC>
0x01                  </CHARACTERISTIC-LIST>

Using the WAP Bookmark object

The SMS and MMS Toolkit makes it easy to generate and deliver WAP Bookmark messages. You can send WAP Bookmark messages using a GSM modem (or GSM phone), or using an SMPP provider. Use the SmsDataWapBookmark object to format the message of the SMS, and use the regular SmsProtocolGsm or SmsProtocolSmpp functions to send the WAP Bookmark formatted message.

The following code snippet shows how to encode the WAP Bookmark message as shown above:

Set objWap              = CreateObject ( "ActiveXperts.SmsDataWapBookmark" )
Set objConstants        = CreateObject ( "ActiveXperts.SmsConstants" )

objWap.URL              = "http://wap.yahoo.com"
objWap.Description      = "WAP Bookmark Message"

objWap.Encode

Used Parameters

URL

The URL of the website we want to send the mobile to. The maximum length of this URL is 255 characters. The URL has to start with "http://" or "https://".

Title

The description for the content that has to be loaded on the mobile phone. The maximum length of this Title is 50 characters.

Sending the encoded data

After all parameters has been set, you have to call the "Encode" function. This function does the actual encoding and returns the encoded data via the 'EncodedMessage' property.

If the "Encode" functions failes, you can check the "LastError" property to see what is going wrong.

The encoded data can be send using the SmsProtocolSmpp or SmsProtocolGsm object.

Sending WAP Bookmark messages using the SmsProtocolDialUp object is not supported.

To retrieve an encode message from the object, you the "GetMessagePart" function. Please note that you have to set the messagetype to "asMESSAGEFORMAT_DATA_UDH" because the WAP Bookmark data is encoded as 8 bit message data and includes UDH information for application port addressing. The samples below demonstrates how to send the messagedata using the SmsProtocolSmpp and SmsProtcolGsm objects:

SmsProtocolSmpp:

' WAP Bookmark VBScript sample

   objSmsProtocol    = CreateObject ( "ActiveXperts.SmsProtocolSmpp" )
   objSmsMessage     = CreateObject ( "ActiveXperts.SmsMessage" )
   objSmsConstants   = CreateObject ( "ActiveXperts.SmsConstants" )
 
   objWap.Encode
  
   objSmsProtocol.Server            = "smpp.activexperts-labs.com"
   objSmsProtocol.SystemID          = "AX008"
   objSmsProtocol.SystemPassword    = "812056"
   
   objSmsProtocol.Connect

   WScript.Echo "Connect, result #" & objSmsProtocol.LastError

   If ( objSmsProtocol.LastError <> 0 ) Then
     WScript.Quit
   End If

   objSmsMessage.Format      = objSmsConstants.asMESSAGEFORMAT_DATA_UDH
   objSmsMessage.Data        = objWap.EncodedMessage
   objSmsMessage.Recipient   = "+31647134225"

   objSmsProtocol.Send ( objSmsMessage )

   objSmsProtocol.Disconnect

SmsProtocolGsm:

   objSmsProtocol  = CreateObject ( "ActiveXperts.SmsProtocolGsm" )
   objSmsMessage   = CreateObject ( "ActiveXperts.SmsMessage" )
   objSmsConstants = CreateObject ( "ActiveXperts.SmsConstants" )
   
   objWap.Encode
   
   ' Set Device
   objSmsProtocol.Device           = "COM1"

   ' Set Message Properties
   objSmsMessage.Format            = objSmsConstants.asMESSAGEFORMAT_DATA_UDH
   objSmsMessage.Recipient         = "+31647134225"
   objSmsMessage.Data              = objWap.EncodedMessage

   objSmsProtocol.Send ( objSmsMessage )