MessageManager SMS and MMS Webservice API
MessageManager SMS and MMS Webservice API
1/14
Table of Contents
2/14
I. Messenger API functions as webservice
This set of functions is designed for sending and receiving SMS/MMS messages and for Inbox
operation in third-party clients. Each function comes in two variants: for UTF-8 and for
Windows-1256 encoding. The function parameters universal to all functions are underlined,
and you can see their full descriptions in the API parameters universal to all functions.
Messenger API uses SOAP services, so you need to add a Web Reference called
‘MessengerService’ to your project before you can compile the examples from this document.
The URL for the Web Service for Zain SMS System is
http://bulkcorporate.sa.zain.com/bms/Soap/Messenger.asmx
For Arabic codepage compatibility you can access the same webservice at
http://bulkcorporate.sa.zain.com/bms/Soap1256/Messenger.asmx
Please use the following code to initialize Messenger API before calling any of its functions:
MessengerSoapClient messenger =
new MessengerService.MessengerSoapClient("MessengerSoap");
// "MessengerSoap" - endpoint name in configuration file
I.1.b. customerUserName
A user is the actual actor who uses the Messaging Platform services. A customer can have
several users who access the Messaging Platform services under the customer account. A
user does not have a balance of their own, when a user is sending messages, their customer
account is charged. Every user has a separate user name, a password, and can have a
separate set of originators.
I.1.c. originatorName
The originator is the name or number that the recipient sees as the signature for the
message received.
3/14
II. Authenticating the user
The Authenticate function authenticates the user specified by the customer ID, user name,
language, and password in MESSAGEMANAGER PLATFORM system.
• customerUserName for the user for whom the list of originators is requested.
• Language—the language in which the client application is going to communicate with
the user.
• userPassword—the password of the user specified.
if (authData.Result == "OK")
{
Console.WriteLine("Hello, Bob");
}
else
{
Console.WriteLine("Error: " + authData.Result);
}
4/14
You can also use the HTTP_Authenticate alias to call this function without using SOAP, by
the means of pure HTTP GET, as shown in the example below:
GET /MessageManager
Platform/soap/Messenger.asmx/HTTP_Authenticate?customerID=string&userName=str
ing&userPassword=string
HTTP/1.1
• customerUserName for the user for whom the list of originators is requested.
• userPassword—the password of the user specified.
• originator—the parameter identical to originatorName
• smsText—the text for the SMS message to be sent.
• recipientPhone—the recipient’s phone numbers separated by commas (the parameter
can contain just one number).
• messageType—the type of the character set used in the SMS text (Latin, Arabic with
Latin numbers, Arabic with Arabic numbers).
• defDate—the parameter specifying the date and time of deferred delivery (must be in
the yyyyMMddhhmmss format).
• flash—the parameter defines whether the SMS message is to be saved in the recipient
phone inbox (True—the message is not saved, False—the message is saved).
• blink—the parameter defines whether the SMS message blinks when onscreen
(applicable for some makes of Nokia mobile phones).
• private—the parameter defines whether the SMS message appears in the account
statement.
5/14
An example of responding to the SendSms function is provided below:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<SendSmsResponse xmlns="http://pmmsoapmessenger.com/">
<SendSmsResult>
<RejectedNumbers>
<string>string</string>
<string>string</string>
</RejectedNumbers>
<TransactionID>string</TransactionID>
<NetPoints>string</NetPoints>
</SendSmsResult>
</SendSmsResponse>
</soap:Body>
</soap:Envelope>
You can also use the HTTP_SendSms alias to call this function without using SOAP, by the
means of pure HTTP GET, as shown in the example below:
GET /MessageManager
Platform/soap/Messenger.asmx/HTTP_SendSms?customerID=string&userName=string&u
serPassword=string&originator=string&smsText=string&recipientPhone=string&mes
sageType=string&defDate=string&blink=string&flash=string&Private=string
HTTP/1.1
• customerUserName for the user for whom the list of originators is requested.
• Language—the language in which the client application is going to communicate with
the user.
• userPassword—the password of the user specified.
• originator—the parameter identical to originatorName.
• binaryBody—the binary body of the SMS message.
• recipientPhone— the recipient’s phone numbers separated by commas (the parameter
can contain just one number).
• defDate—the parameter specifying the date and time of deferred delivery (must be in
the yyyyMMddhhmmss format).
• data_coding—the coding for the binary body of the SMS message.
• esm_class—the parameter related to the coding of the binary body of the SMS
message.
6/14
• PID—the protocol ID.
SendResult binSmsSendResult =
messenger.SendBinarySms(user, originator, smsData , phone, defDate,
string.Empty, string.Empty, string.Empty);
Console.WriteLine();
7/14
V. Sending MMS messages
With the help of the SendMMS function the customer can send MMS messages using the
specified parameters.
First, the paths where to put the ‘SMIL’ file and the MMS content are defined. Then the
GenerateMIME method uses the paths to generate the resulting mm7 file and save it to the
path specified. Then the FileStream method takes the mm7 file and transforms it into a
datastream to be transferred to the SendMMS function.
String mm7FilePath = "D:\\<some_folder_1>\\<some_folder_2>\\<mm7FileName>";
8/14
using (FileStream fs = new FileStream(mm7FilePath, FileMode.Open,
FileAccess.Read))
{
mm7data = new Byte[fs.Length];
fs.Read(mm7data, 0, mm7data.Length);
String mm7DataString = Convert.ToBase64String(mm7data,
Base64FormattingOptions.None);
}
The GenerateMIME method mentioned in the example above puts the SMIL file into the
mm7 file. The GenerateMIME method is detailed in the lengthy example below:
public static void GenerateMIME(String dataDirectoryName, string
outputFileName)
{
DateTime dt = DateTime.Now;
String sMonth = String.Empty;
String sDay = String.Empty;
String sYear = String.Empty;
String sHour = String.Empty;
String sMinute = String.Empty;
String sSecond = String.Empty;
String sMillisecond = String.Empty;
9/14
String[] files = Directory.GetFiles(dataDirectoryName, "*.smil");
String[] a = smilFileFull.Split('\\');
int count = a.Length;
String smilFileName = a[count - 1];
try
{
// header generation
sw.WriteLine("Content-Type: multipart/related;");
sw.WriteLine("\t boundary=\"" + boundary + "\";");
sw.WriteLine("\t start=\"smil_reference_" + smil_reference + "\";");
sw.WriteLine("\t type=\"application/smil\"");
sw.WriteLine("Content-Id: <content_ref_" + content_ref + ">");
// smil inserting
sw.WriteLine("");
sw.WriteLine("--" + boundary);
sw.WriteLine("Content-Id: <smil_reference_" + smil_reference + ">");
sw.WriteLine("Content-Type: application/smil; name=\"" + smilFileName
+ "\"");
sw.WriteLine("Content-location: " + smilFileName);
sw.WriteLine("");
sw.Write(sr.ReadToEnd());
sw.WriteLine("");
//attachments inserting
10/14
}
}
// footer generation
sw.WriteLine("");
sw.WriteLine("--" + boundary + "--");
}
catch (Exception ex)
{
//Exception handling
}
finally
{
sw.Close();
sr.Close();
}
}
(the end of the GenerateMIME method description)
The WriteToMime method mentioned in the example above is responsible for putting the
media files into the same mm7 file. The method is detailed in the example below:
public static void WriteToMime(StreamWriter sw, String boundary,
String contentType, String contentLocation,
String stringArray)
{
sw.WriteLine("");
sw.WriteLine("--" + boundary);
sw.WriteLine("Content-Id: <" + contentLocation + ">;
" + "name=\"" + contentLocation + "\"");
sw.WriteLine("Content-Type: " + contentType);
sw.WriteLine("Content-location: " + contentLocation);
if ( !contentType.StartsWith("text"))
{
sw.WriteLine( "Content-Transfer-Encoding: base64" );
}
sw.WriteLine("");
int RecordsNum = 0;
int iRes = stringArray.Length / 76;
if ((iRes * 76) < stringArray.Length) RecordsNum = iRes + 1;
else RecordsNum = iRes;
String[] a = null;
a = new String[RecordsNum];
int j = 0;
for (int i = 0; i < RecordsNum; i++)
{
if (!(i == RecordsNum - 1)) a[i] = stringArray.Substring(j, 76);
else
{
int iLengthRemain = stringArray.Length - ((RecordsNum - 1) * 76);
a[i] = stringArray.Substring(j, iLengthRemain);
}
sw.WriteLine(a[i]);
j += 76;
}
}
11/14
VI. Getting SMS/MMS message status
To get statuses for both SMS and MMS messages, the GetSmsStatus function is used.
Actually, it operates with the message transactionID which does not depend on the message
type. The GetSmsStatus function returns the delivery status of the specified SMS/MMS
message.
• customerUserName for the user for whom the list of originators is requested.
• Language—the language in which the client application is going to communicate with
the user.
• userPassword—the password of the user specified.
• transactionID—the unique identification of the transaction.
• detailed—Boolean value which defines if detailed statuses for multiple recipients are to
be show. It can be ‘True’ or ‘False’.
12/14
VII. Sending Service SMS messages
With the help of the SendServiceSms function the customer can send service SMS
messages using the specified parameters.
• customerUserName for the user for whom the list of originators is requested.
• userPassword—the password of the user specified.
• originator—the parameter identical to originatorName
• serviceName—the name of the service.
• serviceUrl—the URL of the service.
• recipientPhone—the recipient’s phone numbers separated by commas (the parameter
can contain just one number).
• messageType—the type of the character set used in the SMS text (Latin, Arabic with
Latin numbers, Arabic with Arabic numbers).
• defDate—the parameter specifying the date and time of deferred delivery (must be in
the yyyyMMddhhmmss format).
• flash—the parameter defines whether the SMS message is to be saved in the recipient
phone inbox (True—the message is not saved, False—the message is saved).
• blink—the parameter defines whether the SMS message blinks when onscreen
(applicable for some makes of Nokia mobile phones).
• private—the parameter defines whether the SMS message appears in the account
statement.
13/14
<SendServiceSmsResponse xmlns="http://pmmsoapmessenger.com/">
<SendServiceSmsResult>
<RejectedNumbers>
<string>string</string>
<string>string</string>
</RejectedNumbers>
<TransactionID>string</TransactionID>
<NetPoints>string</NetPoints>
</SendServiceSmsResult>
</SendServiceSmsResponse>
</soap:Body>
</soap:Envelope>
14/14