Upload
others
View
1
Download
0
Embed Size (px)
Citation preview
TeleMessage XML Interface
© 1999-2007 TeleMessage Ltd Page 1 of 63
TeleMessage XML Interface
Version 1.6.3
Document Update Information:
Version Date Author Changes
1.2 06/04/2001 Arthur Veinstein Original version
1.3 1/09/2001 Doron Perelstein
1.3.1 1/11/2001 Arthur Veinstein
1.3.3 10/1/2002 Doron Perelstein
1.3.4 25/4/2002 Arthur Veinstein Added Statuses
1.4 23/1/2003 Yaniv Kunda & Arthur Veinstein
Added message owner; Enabled Cc/Bcc and Change To element to be optional
1.5 03/07/2003 Arthur Veinstein Using the USER_FROM element override. Added REPLIES and FILEURL elements to MESSAGE_STATUS
1.6 19/05/2004 Amichai Rothman Added MIME_TYPE optional elements
1.6.1 12/08/2004 Liona Amado Added sections “How it works”, Code sampes, updates status
1.6.2 28/03/2007 Mikhail Grinfeld Updated for version 5.7 with FILEURL, CALLBACK_PREFERENCE, MMS,removing pager and ICQ., Adding PHP example
1.6.3 01/05/2013 Nadav Harel Added replies to status query
The information in this manual is subject to change without notice. TeleMessage Ltd. assumes no responsibility for any inconsistencies between the actual product and this manual’s description of it.
TeleMessage Ltd. holds the copyright to this manual. All rights are reserved. No part of this publication may be reproduced or transmitted in any form or by any means without prior written consent from TeleMessage Ltd.
Company and product names may be trademarks or registered trademarks of their respective holders
TeleMessage XML Interface
© 1999-2007 TeleMessage Ltd Page 2 of 63
Contents
i. Introduction ........................................................................................................................................ 5
A. Purpose ....................................................................................................................................... 5
B. Objective of this Document ........................................................................................................ 5
C. How it works ............................................................................................................................... 5
D. Terms Used in this Document .................................................................................................... 8
E. XML Submit URL .......................................................................................................................... 8
F. XML References ........................................................................................................................... 8
ii. Elements and Attributes .................................................................................................................. 10
A. TELEMESSAGE ........................................................................................................................... 10
B. TELEMESSAGE_CONTENT .......................................................................................................... 10
C. MESSAGE ................................................................................................................................... 11
D. MESSAGE_INFORMATION ........................................................................................................ 11
E. OWNER ...................................................................................................................................... 12
F. USER_FROM ............................................................................................................................... 13
G. CALLBACK_PREFERENCES ......................................................................................................... 13
H. MESSAGE_CONTENT ................................................................................................................. 14
I. USER_TO ..................................................................................................................................... 14
J. USER_CC ..................................................................................................................................... 15
K. USER_BCC .................................................................................................................................. 15
L. LOCALE ....................................................................................................................................... 16
M. SUBJECT .................................................................................................................................... 16
N. TIME_STAMP ............................................................................................................................ 17
O. SCHEDULE_TO ........................................................................................................................... 18
P. CIML ........................................................................................................................................... 18
Q. DEVICE_INFORMATION ............................................................................................................ 19
R. DEVICE_TYPE ............................................................................................................................. 19
S. DEVICE_VALUE ........................................................................................................................... 20
T. DEVICE_DESCRIPTION ............................................................................................................... 20
TeleMessage XML Interface
© 1999-2007 TeleMessage Ltd Page 3 of 63
U. PARTNER_INFORMATION ........................................................................................................ 21
V. TEXT_MESSAGE ......................................................................................................................... 21
W. PROPERTY_MESSAGE .............................................................................................................. 22
X. PROPERTY_NAME ..................................................................................................................... 22
Y. PROPERTY_VALUE ..................................................................................................................... 23
Z. FILE_MESSAGE ........................................................................................................................... 23
AA. FILE_NAME .............................................................................................................................. 24
BB. MIME_TYPE ............................................................................................................................. 24
CC. FILE_DATA ............................................................................................................................... 25
DD. FILE_REFERENCE ........................................................................ Error! Bookmark not defined.
EE. FILE_DATA_BASE64 ................................................................................................................. 25
FF. FILE_DATA_RAW ...................................................................................................................... 26
GG. LOCALE_LANGUAGE_ID ......................................................................................................... 26
HH. LOCALE_COUNTRY_ID ............................................................................................................ 27
II. COMPANY_NAME ..................................................................................................................... 27
JJ. COMPANY_ID ............................................................................................................................ 27
KK. COMPANY_PASSWORD .......................................................................................................... 28
LL. MESSAGE_INDEX...................................................................................................................... 28
MM. RESPONSE ............................................................................................................................. 29
NN. MESSAGE_ID .......................................................................................................................... 30
OO. MESSAGE_KEY ........................................................................................................................ 31
PP. RESPONSE_STATUS ................................................................................................................. 31
QQ. RESPONSE_STATUS_DESC ..................................................................................................... 32
RR. MESSAGE_STATUS_QUERY .................................................................................................... 32
SS. MESSAGE_STATUS ................................................................................................................... 33
TT. STATUS_ID ............................................................................................................................... 34
UU. STATUS_DESCRIPTION ........................................................................................................... 34
VV. RECIPIENT_STATUS ................................................................................................................. 34
WW. RECIPIENT_NAME ................................................................................................................. 35
XX. DEVICE ..................................................................................................................................... 35
YY. TYPE ......................................................................................................................................... 36
ZZ. VALUE....................................................................................................................................... 37
TeleMessage XML Interface
© 1999-2007 TeleMessage Ltd Page 4 of 63
AAA. STATUS ................................................................................................................................. 37
BBB. DESCRIPTION ........................................................................................................................ 37
CCC. STATUS_DATE ....................................................................................................................... 38
DDD. ANSWER ............................................................................................................................... 38
iii. XML transmitting directions ............................................................................................................ 39
A. Purpose ..................................................................................................................................... 39
B. HTTP POST ................................................................................................................................. 39
Appendix A – Examples: ............................................................................................................................. 39
1. Simple Text Message ................................................................................................................. 39
Appendix B – Statuses to be used in MESSAGE_STATUS element: .......................................................... 46
Appendix C – Response Statuses: .............................................................................................................. 47
Appendix D – Java Code: ............................................................................................................................ 47
1. Post XML .................................................................................................................................... 47
2. Message with attachment ........................................................................................................ 48
3. Message in other language ....................................................................................................... 49
Appendix E – Visual Basic Code:................................................................................................................. 50
1. Post XML .................................................................................................................................... 50
Appendix F – PHP Language Code: ............................................................................................................. 51
1. Post XML .................................................................................................................................... 51
Appendix G – ISO Language Code: ............................................................................................................. 52
Appendix H – ISO Country Code:................................................................................................................ 54
Appendix I – Device Status description table ............................................................................................ 60
TeleMessage XML Interface
© 1999-2007 TeleMessage Ltd Page 5 of 63
i. Introduction
A. Purpose
The purpose of this DTD is to define an application-level communication for the TeleMessage messaging services. It defines the structures being sent and received between the TeleMessage messaging server and the partner’s application server.
B. Objective of this Document
This document provides documentation for the TeleMessage Document Type Definition (DTD). It defines the different elements, attribute names and the types of information that they are intended for. This document also describes the syntax of the DTD, by indicating the allowable order, frequency of elements and attributes in any document based on this DTD.
C. How it works
Below is a list of steps used to send and trace a message: (1) External system sends message to be delivered using TeleMessage Multi-Alert XML (2) TeleMessage receives message and reports MessageID and MessageKey for future status and reply queries (3) TeleMessage messaging center sends message to devices and collects replies (4) External system queries TeleMessage for status and replies (5) TeleMessage reports replies & delivery status back to external system
TeleMessage XML Interface
© 1999-2007 TeleMessage Ltd Page 6 of 63
TeleMessage XML Interface
© 1999-2007 TeleMessage Ltd Page 7 of 63
TeleMessage XML Interface
© 1999-2007 TeleMessage Ltd Page 8 of 63
D. Terms Used in this Document
Element - A unit of XML data, delimited by tags. An XML element can enclose other elements. Wrapper Element – an element, which includes more than one Element. Its purpose is to “wrap” a number of related elements. Tag – a unit of markup. XML consists of open s and close (all open tags must have a corresponding close tag), and empty s. Attribute - A qualifier on an XML tag that provides additional information (ie: ). Markup – a combination of tags, content (text) and entities. Partner – The client/customer/company that is implementing this DTD, passing information/data to the TeleMessage system. Originator – A client/customer/user of the partner of TeleMessage, who originate the message Recipient – A client/customer/user/PSTN carrier/SMS provider who receives the messages from the TeleMessage system.
E. XML Submit URL
Submit your case-sensitive XML as an HTTP form post to the following URL: http://xml.telemessage.com/partners/xmlMessage.jsp There is a test form to post XML data into at: http://xml.telemessage.com/partners/xmlMessageTest.jsp
F. XML References
A reference allows you to include additional text or markup in an XML document. References always begin with the character “&” (which is specially reserved) and end with the character “;”. XML has two kinds of references:
TeleMessage XML Interface
© 1999-2007 TeleMessage Ltd Page 9 of 63
ENTITY REFERENCES An entity reference, like “&”, contains a name (in this case, “amp”) between the start and end delimiters. The name refers to a predefined string of text and/or markup, like a macro in the C or C++ programming languages. CHARACTER REFERENCES A character references, like “&”, contains a hash mark (“#”) followed by a number. The number always refers to the Unicode code for a single character, such as 65 for the letter “A” or 233 for the letter “י”, or 8211 for an en-dash. For advanced uses, XML provides a mechanism for declaring your own entities, but that is outside the scope of this document. XML also provides five pre-declared entities that you can use to escape special characters in an XML document: For example, the corporate name “AT&T” should appear in the XML markup as “AT&T”: the XML parser will take care of changing “&” back to “&” automatically when the document is processed. You must use character references for greek and other extended characters.
Character Predeclared Entity
& &
< <
> >
" "
' '
TeleMessage XML Interface
© 1999-2007 TeleMessage Ltd Page 10 of 63
ii. Elements and Attributes It is important to note that XML is case sensitive. Therefore, all elements and attributes in documents based on this DTD must match the case as indicated herein. All documents based on the TeleMessage DTD shall begin as follows: Note: the ellipsis (…) in the above code indicates missing data. This data will vary from case to case and the correct value must be determined at the time of implementation.
A. TELEMESSAGE
TELEMESSAGE is the root element of any document based on this DTD. It is used to transmit the message content (for messages to be delivered to a recipient) and other related information between TeleMessage and partner’s system. TELEMESSAGE is a wrapper element that will hold all other elements in this document. DTD Fragment Structure TELEMESSAGE is allowed the following markup: • One TELEMESSAGE_CONTENT (from partner to TeleMessage) elements AND • One VERSION element Attributes None
Example
See Appendix A.
B. TELEMESSAGE_CONTENT
TELEMESSAGE_CONTENT contains one of the basic actions that can be transmitted in this XML. DTD Fragment Structure TELEMESSAGE_CONTENT is allowed the following markup: • One or More MESSAGE (from partner to TeleMessage) elements OR
TeleMessage XML Interface
© 1999-2007 TeleMessage Ltd Page 11 of 63
• One or More RESPONSE (from TeleMessage to partner) element OR • One MESSAGE_STATUS_QUERY (from partner to TeleMessage) element OR • One or More MESSAGE_STATUS (from TeleMessage to partner) elements Attributes None Example
See Appendix A
C. MESSAGE
MESSAGE is a wrapper element used to contain all the data that the partner delivers to the TeleMessage system. This includes destination information, message content, and the sent date among other information. DTD Fragment Structure MESSAGE may appear one or more times in TELEMESSAGE, as long as RESPONSE, MESSAGE_STATUS_QUERY or MESSAGE_STATUS do not also appear. MESSAGE is allowed the following markup (note: Elements must appear in the order listed below): • One MESSAGE_INFORMATION element • Zero or One OWNER element • One USER_FROM • Zero or One CALLBACK_PREFERENCES element • Zero or One MESSAGE_CONTENT element • Zero or One USER_TO element • Zero or One USER_CC element • Zero or One USER_BCC element Attributes None Example Note: ellipsis (…) has been used to indicate omitted data/content/markup. …
… … …
…
D. MESSAGE_INFORMATION
TeleMessage XML Interface
© 1999-2007 TeleMessage Ltd Page 12 of 63
MESSAGE_INFORMATION is a wrapper element used to contain any other information beside the message content. The data will include the locale (language) for the phone/web menus, subject, date/time the message was sent and the date for scheduling a postponed delivery of a message (“scheduled message”). DTD Fragment Structure MESSAGE_INFORMATION is the first element allowed in MESSAGE and must appear one time only, immediately following the open tag. MESSAGE_INFORMATION is allowed the following markup (note: Elements must appear in the order listed below): • Zero or One LOCALE element • Zero or One SUBJECT element • One TIME_STAMP element • Zero or one SCHEDULE_TO element Attributes None Example Note: ellipsis (…) has been used to indicate omitted data/content/markup. …
… … … …
…
E. OWNER
OWNER is a wrapper element used to contain the entire data specific to each message owner user. OWNER will include one CIML (Customer Identity Markup Language) element in case the owner is the partner customer or one PARTNER_INFORMATION element in case the owner is the partner himself. The data will be used as the message “Owner” in relation to its billing respects and other preferences. Note: The OWNER element should only be used for billing purposes as an option to charge the message on a different user then the USER_FROM. Messages which are sent using the OWNER element will not appear in the sender Inbox folder in the Web GUI, and the replies to them will not be sent to the sender reply devices. In order to be able to track messages and get the replies to them a USER_FROM element should be used. DTD Fragment Structure OWNER is required to appear once in the MESSAGE element, immediately following close tag.
TeleMessage XML Interface
© 1999-2007 TeleMessage Ltd Page 13 of 63
OWNER is allowed the following markup: • Zero or One CIML element • Zero or One PARTNER_INFORMATION element Attributes None Example Note: ellipsis (…) has been used to indicate omitted data/content/markup. …
… …
F. USER_FROM
USER_FROM is a wrapper element used to contain the entire data specific to each message originator. USER_FROM will include one CIML (Customer Identity Markup Language) element in case the originator is the partner customer or one PARTNER_INFORMATION element in case the originator is the partner himself. The data will be used as the message “Sender” in all devices that receives the message. DTD Fragment Structure USER_FROM is required to appear once in the MESSAGE element, following either (if included) or close tag. USER_FROM is allowed the following markup: • Zero or One CIML element • Zero or One PARTNER_INFORMATION element Attributes None Example Note: ellipsis (…) has been used to indicate omitted data/content/markup. …
… …
G. CALLBACK_PREFERENCES
CALLBACK_PREFERENCES is a wrapper element used to contain the entire data specific to each message callback preference. CALLBACK_PREFERENCES defines "reply to" device.
DTD Fragment
TeleMessage XML Interface
© 1999-2007 TeleMessage Ltd Page 14 of 63
Structure CALLBACK_PREFERENCES is an optional element and may appear zero or one times in the MESSAGE. CALLBACK_PREFERENCES is allowed the following markup:
1 – Reply to email
2 – Reply to mobile
Attributes None Example < CALLBACK_PREFERENCES>1
H. MESSAGE_CONTENT
MESSAGE_CONTENT is a wrapper element used to contain the actual body of the message(s) that is to be sent to the receiver of the message(s). DTD Fragment Structure MESSAGE_CONTENT is an optional element and may appear zero1 or one times in the MESSAGE element. MESSAGE_CONTENT is allowed the following markup: • Zero or More TEXT_MESSAGE elements • Zero or More PROPERTY _MESSAGE elements • Zero or More FILE _MESSAGE elements Attributes None Example Note: ellipsis (…) has been used to indicate omitted data/content/markup. … The message goes here. … 1 As long as SUBJECT element is included in MESSAGE_INFORMATION
I. USER_TO
USER_TO is a wrapper element used to contain the entire data specific to each message recipient. USER_TO will include one or more CIML (Customer Identity Markup Language) elements. The data will include the type of the device and the number/address the message should be sent to, along other recipient info. DTD Fragment
TeleMessage XML Interface
© 1999-2007 TeleMessage Ltd Page 15 of 63
Structure USER_ TO is an optional element and may appear zero2 or one times in the MESSAGE element, following either (if included) or close tag. USER_TO is allowed the following markup: • One or More CIML element Attributes None Example Note: ellipsis (…) has been used to indicate omitted data/content/markup. ………
J. USER_CC
USER_CC is a wrapper element used to contain the entire data particular to each CC (Carbon Copy) message recipient. USER_CC will include one or more CIML (customer identity) elements. The data will include the type of device and the number/address the message should be sent to, along other recipient info. DTD Fragment Structure USER_CC is an optional element and may appear zero or one times in the MESSAGE element, following either (if included) or close tag. USER_CC is allowed the following markup: • One or More CIML element 2 As long as USER_CC or USER_BCC element is included in MESSAGE
Attributes None Example Note: ellipsis (…) has been used to indicate omitted data/content/markup. ………
K. USER_BCC
USER_BCC is a wrapper element used to contain the entire data particular to each BCC (Blind Carbon Copy) message recipient. USER_BCC will include one or more CIML (customer identity) elements. The data will include the type of device and the number/address the message should be sent to, along other recipient info.
TeleMessage XML Interface
© 1999-2007 TeleMessage Ltd Page 16 of 63
DTD Fragment Structure USER_BCC is an optional element and may appear zero or one times in the MESSAGE element, following either , or close tag. USER_BCC is allowed the following markup: • One or More CIML element Attributes None Example Note: ellipsis (…) has been used to indicate omitted data/content/markup. ………
L. LOCALE
LOCALE is a wrapper element used to hold the specific language to be used in the message sent. If provided, it must include the following elements: LOCAL_LANGUAGE_ID and LOCALE_COUNTRY_ID. The default language to be used in this field is US English. DTD Fragment Structure LOCALE may appear one time only in the MESSAGE_INFORMATION, immediately following the open tag. See “MESSAGE_INFORMATION” in this document for a complete description of the structure of that element. LOCALE is allowed the following markup (note: Elements must appear in the order listed below): • One LOCALE_LANGUAGE_ID element • One LOCALE_COUNTRY_ID element Attributes None Example Note: ellipsis (…) has been used to indicate omitted data/content/markup. …
… …
…
M. SUBJECT
SUBJECT contains the text to enter in the “subject” field in the end devices.
TeleMessage XML Interface
© 1999-2007 TeleMessage Ltd Page 17 of 63
DTD Fragment Structure SUBJECT may appear zero3 or one times as part of the MESSAGE_INFORMATION element, following either close tag or open tag. See “MESSAGE_INFORMATION” in this document for complete description of the structure of that element. The content of SUBJECT is Parsable Character Data (PCDATA). No markup is allowed. The SUBJECT has to be alphanumeric with no special punctuation4. The maximum length of the SUBJECT element is 960 characters (including spaces. In languages other than English this size maybe smaller). The SUBJECT of Messaging requests with SUBJECT longer than 960 characters will be trimmed. Attributes None Example …Welcome to TeleMessage !!!… 3 As long as MESSAGE_CONTENT, with at least one TEXT_MESSAGE, is included in MESSAGE
4 For example, ~, ^, _ | \, [], {}, “, ‘ &, and %
N. TIME_STAMP
TIME_STAMP indicates the time the message was sent (or was delivered to the TeleMessage system (by another party)). It is used in the MESSAGE element. TIME_STAMP identifies the date/time the originator sent the message. This value is only used for logging/reporting purposes. The content of the tags should conform to the following format: yyyymmdd hh:mm:ss Hours must be expressed in Military hours, with a leading zero. Please not that the time zone is GMT+0. DTD Fragment Structure TIME_STAMP is required to appear once in the MESSAGE_INFORMATION element, following , close tag, or open tag. The content of TIME_STAMP is Parsable Character Data (PCDATA). No markup is allowed. Attributes None Example …19990603 01:36:45…
TeleMessage XML Interface
© 1999-2007 TeleMessage Ltd Page 18 of 63
O. SCHEDULE_TO
SCHEDULE_TO is used for scheduling a message to a later time for a postponed message delivery. This is to give the message originator the ability to send messages at different delayed seconds/minutes/hours/days/months/years for many different purposes (e.g. different time zones in the world). The content of the tag should conform to the following format: yyyymmdd hh:mm:ss Hours must be expressed in Military hours, with a leading zero. Please not that the time zone is GMT+0. DTD Fragment Structure SCHEDULE_TO may appear zero or one times in MESSAGE_INFORMATION, following close tag. See “MESSAGE_INFORMATION” in this document for a complete description of the structure of that element. The content of SCHEDULE_TO is Parsable Character Data (PCDATA). No markup is allowed. Attributes None Example …20010101 18:30:00…
P. CIML
CIML (Customer Identity Markup Language) is a wrapper element used to contain all data particular to each message originator/recipient. It is used in the MESSAGE (indicate the message originator), USER_TO, USER_CC and USER_BCC elements. DTD Fragment Structure The CIML must appear one time only in the USER_FROM element (as long as PARTNER_INFORMATION do not also appear) immediately following open tag. The same element is used also in the USER_TO, USER_CC, USER_BCC elements. The CIML is allowed the following markup (note: Elements must appear in the order listed below): • One NAML element • One or More device_information elements Note: If the CIML appear in the USER_FROM element and contains device_information element with device_type =”SMS”, the device value will be used as a sender number in the SMS message. Attributes None
TeleMessage XML Interface
© 1999-2007 TeleMessage Ltd Page 19 of 63
Q. DEVICE_INFORMATION
DEVICE_INFORMATION is a wrapper element used to contain a recipient device data, this information could include a recipient phone number, email address etc. DTD Fragment Structure DEVICE_INFORMATION must appear one or more times in CIML element, immediately following the close tag. DEVICE_INFORMATION is allowed the following markup (note: Elements must appear in the order listed below): • One DEVICE_TYPE element • One DEVICE_VALUE element • Zero or One DEVICE_DESCRIPTION element Attributes None. Example …
… …
…
R. DEVICE_TYPE
DEVICE_TYPE indicates the device type for sending a message to. There are several predefined attribute values, as follows: • HomeNumber • BusinessNumber • BusinessFax • MMS • MobileNumber • SMS • EmailAddress *TeleMessage will add additional supported devices from time to time DTD Fragment
TeleMessage XML Interface
© 1999-2007 TeleMessage Ltd Page 20 of 63
DEVICE_TYPE (HomeNumber | BusinessNumber | BusinessFax | MMS | MobileNumber | SMS | EmailAddress) #REQUIRED> Structure DEVICE_TYPE must appear one time in a DEVICE_INFORMATION element, immediately following the open tag. DEVICE_TYPE is an empty element, so it doesn’t require a close tag or content. Empty tags must have a “/” before the close delimiter “>”. Attributes DEVICE_TYPE is the only attribute on DEVICE_TYPE. It is required, and has several set values, as described above. There is no default value, so the attribute must be defined each time DEVICE_TYPE occurs in a document. Example OR
S. DEVICE_VALUE
DEVICE_VALUE is used to indicate a device value (like email address, phone number etc.). DTD Fragment Structure DEVICE_VALUE must appear one time in a DEVICE_INFORMATION element, immediately following the close tag. The content of DEVICE_VALUE is Parsable Character Data (PCDATA). No markup is allowed. Attributes None Example [email protected]
T. DEVICE_DESCRIPTION
DEVICE_DESCRIPTION is used to indicate a device description other then the declared type. For example mobile description could be “Cellular Phone”. DTD Fragment Structure DEVICE_ DESCRIPTION may appear zero or one time in a DEVICE_INFORMATION element, immediately following the close tag.
TeleMessage XML Interface
© 1999-2007 TeleMessage Ltd Page 21 of 63
The content of DEVICE_ DESCRIPTION is Parsable Character Data (PCDATA). No markup is allowed. Attributes None Example CELLULAR
U. PARTNER_INFORMATION
PARTNER_INFORMATION is a wrapper element used to contain all data particular to each message originator for a specific client (or customer) of TeleMessage (i.e. a partner company). This element allows the TeleMessage system to recognize and bill the correct originator company/client of TeleMessage. This information is pre-defined by a TeleMessage account manager and so is also constant for each partner/client. DTD Fragment Structure PARTNER_INFORMATION must appear one time only in the USER_FROM (as long as ciml_record do not also appear) immediately following open tag. PARTNER_INFORMATION is allowed the following markup (note: Elements must appear in the order listed below): • One COMPANY_NAME element • One COMPANY_ID element • Zero or One COMPANY_PASSWORD element Attributes None Example Note: ellipsis (…) has been used to indicate omitted data/content/markup. …
… … …
…
V. TEXT_MESSAGE
TEXT_MESSAGE contains the actual content of the message that is to be sent to the end user receiver. DTD Fragment Structure
TeleMessage XML Interface
© 1999-2007 TeleMessage Ltd Page 22 of 63
TEXT_MESSAGE may appear zero or more times in MESSAGE_CONTENT element. See “MESSAGE_CONTENT” in this document for complete description of the structure of that element. The content of TEXT_MESSAGE is TEXT element, which is a Parsable Character Data (PCDATA). No markup is allowed. The TEXT_MESSAGE has to be alphanumeric with no special punctuation5. The maximum length of the TEXT_MESSAGE element is 4000 characters including spaces. Messaging requests with TEXT_MESSAGE longer than 4000 characters will be rejected with an error status response (see Appendix B). Attributes None Example …
0 This is a text message!
…
W. PROPERTY_MESSAGE
PROPERTY_MESSAGE contains a property and its value. This is predominantly used for special messages for different clients of TeleMessage. It is handled differently for each client. e.g. if the customer has prerecorded sentences with different call flows, and he wants to send a specific message according to a specific call flow. DTD Fragment Structure PROPERTY_MESSAGE may appear zero or more times in MESSAGE_CONTENT element.
5 For example, ~, ^, _ | \, [], {}, “, ‘ &, and %
Attributes None Example
2 INTERACTIVE true
X. PROPERTY_NAME
PROPERTY_NAME is the name of the property. This is a predefined value that will be provided by a TeleMessage account manager.
TeleMessage XML Interface
© 1999-2007 TeleMessage Ltd Page 23 of 63
DTD Fragment Structure PROPERTY_NAME must appear once in PROPERTY_MESSAGE element. Attributes None Example INTERACTIVE
Y. PROPERTY_VALUE
PROPERTY_VALUE is the value of a property (See PROPERTY_MESSAGE for more information) DTD Fragment Structure PROPERTY_VALUE must appear once in PROPERTY_MESSAGE element. Attributes None Example true
Z. FILE_MESSAGE
FILE_MESSAGE is used to attach a file to a message. The FILE_MESSAGE element includes sub-elements that deliver the following information: The name of the file as the end-user will see, the file data (content) and the file type. See the FILE_NAME, MIME_TYPE and FILE_DATA elements for more information. DTD Fragment Structure FILE_MESSAGE may appear zero or more times in MESSAGE_CONTENT element. Note: In order to send MMS as slide show, insert SMIL (according to http://www.ietf.org/rfc/rfc4536.txt) as file attachment (Use application/smil mime type) else if you use regular file attachment default SMIL will be created. Important to define recipient type MMS (see section YYY. Type).
http://www.ietf.org/rfc/rfc4536.txt
TeleMessage XML Interface
© 1999-2007 TeleMessage Ltd Page 24 of 63
Attributes None Example
1 truste.gif image/gif
http://www.telemessage.com/images/homepage/hp_truste.gif
AA. FILE_NAME
FILE_NAME contains the name of the file that will be presented to the end user (only the name itself , without the full path to the file). DTD Fragment Structure FILE_NAME must appear one time in FILE_MESSAGE element. Attributes None Example Special_Message.wav
BB. MIME_TYPE
MIME_TYPE contains the mime type of the file. If absent the mime type is automatically determined according to the file name extension (for common file types). See http://www.iana.org/assignments/media-types/ for the list of registered mime types. DTD Fragment Structure MIME_TYPE may appear zero or one time in FILE_MESSAGE element. Note: In order to send MMS use application/smil mime type.
http://www.iana.org/assignments/media-types/http://www.iana.org/assignments/media-types/
TeleMessage XML Interface
© 1999-2007 TeleMessage Ltd Page 25 of 63
Attributes None Example text/html
CC. FILE_DATA
FILE_DATA contains the content of the file to be attached, either as an http URL from which the actual file will be retrieved, a base64 encoded file, or a raw file. Exactly one of these must appear within a FILE_DATA element. See the FILE_REFERENCE, FILE_DATA_BASE64 and FILE_DATA_RAW elements for details. DTD Fragment Structure FILE_DATA must appear one time in FILE_MESSAGE element. Attributes None Example
AB4D2DGLG542FF…
DD. FILE_DATA_BASE64
FILE_DATA_BASE64 is a file encoded using the Base64 encoding format. The actual file content is provided here in the Base64 format. More information on Base64 can be obtained from http://www.ietf.org/rfc/rfc1521.txt DTD Fragment Structure FILE_DATA_BASE64 may appear zero or one time in FILE_DATA element. Attributes None Example
AB4D2DGLG542FF…
http://www.ietf.org/rfc/rfc1521.txt
TeleMessage XML Interface
© 1999-2007 TeleMessage Ltd Page 26 of 63
EE. FILE_DATA_RAW
FILE_DATA_RAW is a file whose content is specified directly within this element. Often a CDATA XML tag is useful here so that XML reserved characters such as ‘’ can appear within the file content without causing parse errors. DTD Fragment Structure FILE_DATA_RAW may appear zero or one time in FILE_DATA element. Example
This is my file’s content!]]>
FF. LOCALE_LANGUAGE_ID
LOCALE_LANGUAGE_ID is used to choose the language, which will be used by the system through the different messaging devices: Telephony, email, SMS, MMS and fax. For example in the telephony it will be to choose the TTS (Text To Speech) engines to read the message to telephone devices. In emails it will be used to choose the correct language for the words: “subject”, ”to”, “from” etc. If the field is empty the default is English. (e.g. EN – English). TeleMessage is in the process of adding more languages continuously. If you need to use a specific language you must check if the language is supported by TeleMessage (to do so please consult your account manager). DTD Fragment Structure LOCALE_LANGUAGE_ID is required to appear once in the LOCALE, immediately following open tag. See “LOCALE” in this document for complete description of the structure of that element. The content of LOCALE_LANGUAGE_ID is Parsable Character Data (PCDATA) but should be based upon ISO-639 Language Code (see Appendix D). No markup is allowed. Attributes None Example …EN…
TeleMessage XML Interface
© 1999-2007 TeleMessage Ltd Page 27 of 63
GG. LOCALE_COUNTRY_ID
LOCALE_COUNTRY_ID is used to indicate the country (to distinguish between different pronunciations) which will be used by TTS engines to read the message to telephone devices (e.g. Great Britain or US English). DTD Fragment Structure LOCALE_COUNTRY_ID is required to appear once in the LOCALE, immediately following close tag. See “LOCALE” in this document for complete description of the structure of that element. The content of LOCALE_COUNTRY_ID is Parsable Character Data (PCDATA) but should be based upon ISO-3166 Country Code (see Appendix E). No markup is allowed. Attributes None Example …US…
HH. COMPANY_NAME
COMPANY_NAME is used to indicate the name of the partner. Messages may be initiated by the partner them self, or via a customer who sends the message to the partner, who passes the message on to the TeleMessage system. If this element is provided then the “Sender” of the message will be the COMPANY_NAME. DTD Fragment Structure COMPANY_NAME is the first element allowed in PARTNER_INFORMATION and must appear one time only, immediately following open tag. See “PARTNER_INFORMATION” in this document for complete description of the structure of that element. The content of COMPANY_NAME is Parsable Character Data (PCDATA). No markup is allowed. Attributes None Example …NTT DoCoMo…
II. COMPANY_ID
TeleMessage XML Interface
© 1999-2007 TeleMessage Ltd Page 28 of 63
COMPANY_ID is used to authenticate the partner. Each partner is assigned a unique COMPANY_ID. The TeleMessage Data Base creates the unique COMPANY_ID value for the partner. Please contact your account manager to get your COMPANY_ID. DTD Fragment Structure COMPANY_ID is required to appear once in the PARTNER_INFORMATION, immediately following close tag. See “PARTNER_INFORMATION” in this document for complete description of the structure of that element. The content of COMPANY_ID is Parsable Character Data (PCDATA). No markup is allowed. Attributes None Example …245…
JJ. COMPANY_PASSWORD
COMPANY_PASSWORD is used to authenticate the partner. Each partner is assigned a COMPANY_PASSWORD. Please contact your account manager to get your COMPANY_PASSWORD or change it. DTD Fragment Structure COMPANY_PASSWORD is required to appear once in the PARTNER_INFORMATION, immediately following close tag. See “PARTNER_INFORMATION” in this document for complete description of the structure of that element. The content of COMPANY_PASSWORD is Parsable Character Data (PCDATA). No markup is allowed. Attributes None Example …HY7F3FGS…
KK. MESSAGE_INDEX
MESSAGE_INDEX specifies the location of the message. A message is composed out of several elements, which their order may be of different importance to be played/viewed for the end user. The following elements must include the MESSAGE_INDEX element when provided: FILE_MESSAGE, TEXT_MESSAGE or PROPERTY_MESSAGE. The value 0 is the first message, 1 is the second, and so on.
TeleMessage XML Interface
© 1999-2007 TeleMessage Ltd Page 29 of 63
Important: (1) The MESSAGE_INDEX value must be unique in every different MESSAGE_INDEX element in the XML file. (2) The messages indexes must be sequential and begin from zero. DTD Fragment Structure MESSAGE_INDEX is the first element allowed in TEXT_MESSAGE, PROPERTY_MESSAGE and FILE_MESSAGE. MESSAGE_INDEX must appear one time only, immediately following the , and open tag. The content of MESSAGE_INDEX is Parsable Character Data (PCDATA). No markup is allowed. Attributes None Example
1 This is the second part of the message/TEXT>
0 This is the first part of the text message.
The above XML example will render to the following sentence for the end user: “This is the first part of the text message. This is the second part of the message.”
LL. RESPONSE
RESPONSE is a wrapper element used to acknowledge a received message by the TeleMessage system. The response can be of 2 kinds: a successfully received message will produce a RESPONSE, which includes the MESSAGE_ID and MESSAGE_KEY. An unsuccessful received message will produce a RESPONSE, which includes an error REPONSE_STATUS and RESPONSE_STATUS_DESC (see Appendix B). RESPONSE describes the status of the message after TeleMessage has received it from the partner (and before it has been sent out to the end user receiver). To receive the status of the message delivery, a partner must initiate a MESSAGE_STATUS_QUERY request. DTD Fragment Structure
TeleMessage XML Interface
© 1999-2007 TeleMessage Ltd Page 30 of 63
RESPONSE may appear one time or more in TELEMESSAGE, as long as MESSAGE, MESSAGE_STATUS_QUERY, or MESSAGE_STATUS do not also appear. RESPONSE is allowed the following markup (note: Elements must appear in the order listed below): One or more of the following set: • Zero or One MESSAGE_ID element • Zero or One MESSAGE_KEY element • One RESPONSE_STATUS element • Zero or One RESPONSE_STATUS_DESC element Attributes None Example …
… … …
…
MM. MESSAGE_ID
MESSAGE_ID contains the value of a unique identifier for each message in the TeleMessage system. It is used to track messages throughout the system. Therefore, the MESSAGE_ID has to be unique for each message throughout the lifetime of the application, except in the case when the previous delivery attempt of the message fails. TeleMessage’s Data Base will generate the identifier after each valid MESSAGE sent, and may be used in any RESPONSE, MESSAGE_STATUS_QUERY or MESSAGE_STATUS documents that are relevant to that particular message, as long as the documents are parsed properly. DTD Fragment Structure MESSAGE_ID appears in RESPONSE, MESSAGE_STATUS and MESSAGE_STATUS_QUERY. It is the first element in RESPONSE, but may appear zero or one times depending if the MESSAGE document returns a successful status (see Appendix B). In MESSAGE_STATUS it is the first element and is allowed once. In MESSAGE_STATUS_QUERY it is the only element and must appear one or more times. The content of MESSAGE_ID is Parsable Character Data (PCDATA). No markup is allowed. Attributes None Example 77777
TeleMessage XML Interface
© 1999-2007 TeleMessage Ltd Page 31 of 63
NN. MESSAGE_KEY
MESSAGE_KEY is the unique key of a message in the TeleMessage system. The key is used for security reasons to acquire the information about the message. This is similar to having a “Password” accompanying a “User ID” to secure the entrance to the system. The TeleMessage Data Base generates the MESSAGE_KEY data randomly. DTD Fragment Structure MESSAGE_KEY appears in RESPONSE and MESSAGE_STATUS_QUERY immediately following the close tag. Attributes None Example 10021016319846572323417266385885
OO. SHOW_REPLIES
SHOW_REPLIES is a Boolean key. The key is used for indicating if to show the text replies of a message. DTD Fragment Structure SHOW_REPLIES appears in MESSAGE_STATUS_QUERY immediately following the close tag. The valid values are true / false. The default value is false. Attributes None Example < SHOW_REPLIES >true
PP. RESPONSE_STATUS
RESPONSE_STATUS indicates whether the message was accepted by TeleMessage's system or not (see Appendix B for possible values).
TeleMessage XML Interface
© 1999-2007 TeleMessage Ltd Page 32 of 63
DTD Fragment Structure RESPONSE_STATUS must appear one time only in a RESPONSE element (it will appear multiple times if the set is repeated – see RESPONSE for more detail) immediately following close tag. Attributes None. Example …100
QQ. RESPONSE_STATUS_DESC
RESPONSE_STATUS_DESC (Response Status Description) is used to describe the status. This is the verbal description of the RESPONSE_STATUS data (which is a number). The content of the text in tags is determined by the value of the RESPONSE_STATUS element. This element may not appear if the received message status is a successful one. DTD Fragment Structure RESPONSE_STATUS_DESC may appear zero or one times in a RESPONSE element, immediately following the RESPONSE_STATUS element. The content of RESPONSE_STATUS_DESC is Parsable Character Data (PCDATA). No markup is allowed. Attributes None Example User does not exist in the system OR Invalid User Password
RR. MESSAGE_STATUS_QUERY
MESSAGE_STATUS_QUERY is used to query the TeleMessage system about the status of a message delivery to message recipient. The query is based on Message ID values. DTD Fragment
TeleMessage XML Interface
© 1999-2007 TeleMessage Ltd Page 33 of 63
Structure MESSAGE_STATUS_QUERY may appear one time only in TELEMESSAGE, as long as MESSAGE, RESPONSE, or MESSAGE_STATUS do not also appear. MESSAGE_STATUS_QUERY is allowed the following markup: • One or More MESSAGE_ID elements • One or More MESSAGE_KEY elements One or More SHOW_REPLIES elements Attributes None. Example …
12345 FA64KUR4E12345 344344 YAG4KRRVE344344
…
SS. MESSAGE_STATUS
MESSAGE_STATUS is a wrapper element used to send a message to the partner indicating the status of the message after it has been sent from TeleMessage’s system to the recipient. DTD Fragment Structure MESSAGE_STATUS may appear one time only in TELEMESSAGE, as long as MESSAGE, RESPONSE, or MESSAGE_STATUS_QUERY do not also appear MESSAGE_STATUS is allowed the following markup (note: Elements must appear in the order listed below): • One STATUS_ID element • One STATUS_DESCRIPTION element • One MESSAGE_ID element • Zero or More RECIPIENT_STATUS elements Attributes None. Example …
… … …
…
TeleMessage XML Interface
© 1999-2007 TeleMessage Ltd Page 34 of 63
TT. STATUS_ID
STATUS_ID is used to indicate a delivery status identifier being produced by TeleMessage system. See Appendix E. DTD Fragment Structure STATUS_ID must appear one time only in a MESSAGE_STATUS element, immediately following the open tag. The content of STATUS_ID is Parsable Character Data (PCDATA). No markup is allowed. Attributes None Example 1000
UU. STATUS_DESCRIPTION
STATUS_DESCRIPTION is used to indicate a description for each status. DTD Fragment Structure STATUS_ DESCRIPTION must appear one time only in a MESSAGE_STATUS element, immediately following the close tag. The content of STATUS_ DESCRIPTION is Parsable Character Data (PCDATA). No markup is allowed. Attributes None Example Message delivered successfully
VV. RECIPIENT_STATUS
RECIPIENT_STATUS element is a wrapper element used to describe recipient status according to device. DTD Fragment Structure
TeleMessage XML Interface
© 1999-2007 TeleMessage Ltd Page 35 of 63
RECIPIENT_STATUS may appear zero or More time in MESSAGE_STATUS. RECIPIENT_STATUS element allowed the following markup: • One RECIPIENT_NAME element • One DEVICE element Attributes None Example …< RECIPIENT_STATUS >
… …
…..
WW. RECIPIENT_NAME
RECIPIENT_NAME element is a wrapper element used to contain recipient name. DTD Fragment Structure RECIPIENT_ NAME has to appear one time in RECIPIENT_STATUS. Attributes None Example …
XX. DEVICE
DEVICE is used to specify a message recipient device status (and answer to a question asked by the partner (can be sent originally from a partner’s customer). The question can be defined using the PROPERETY_MESSAGE element. DTD Fragment Structure DEVICE may appear one time in the RECIPIENT_STATUS. DEVICE is allowed the following markup (note: Elements must appear in the order listed below): • One TYPE element • One VALUE element • One STATUS element • One DESCRIPTION element • One STATUS_DATE element
TeleMessage XML Interface
© 1999-2007 TeleMessage Ltd Page 36 of 63
• One or zero ANSWER element Attributes None Example
30 972-3-9225252 Ext. 918 2400 Call completed successfully 20070321 11:41:10 1
YY. TYPE
TYPE is used to specify the Device type of the recipient device. This element’s value is determined as follows: Type Description 10 Mobile Phone 20 Business Phone 30 Home Phone 40 Email 60 SMS 80 Fax 120 MMS Note: Not all ISPs and mobile devices support sending and/or receiving MMS messages. If ISP or recipient phone device don't support MMS, you will get failed status for sending message with type="MMS" (see Appendix H). Note: In order to send MMS as slide show, insert SMIL (according to http://www.ietf.org/rfc/rfc4536.txt) as file attachment (see section Z. FILE_MESSAGE), else if you use regular file attachment (section Z. FILE_MESSAGE) default SMIL will be created. DTD Fragment Structure TYPE must appear once in the DEVICE. Attributes None Example
http://www.ietf.org/rfc/rfc4536.txt
TeleMessage XML Interface
© 1999-2007 TeleMessage Ltd Page 37 of 63
30
ZZ. VALUE
VALUE is used to specify the device value. This is the actual destination of the device. The value can be a phone number, email address etc. depends on the TYPE of the device. DTD Fragment Structure VALUE must appear once in the DEVICE Attributes None Example 972-3-9225252 Ext. 918
AAA. STATUS
STATUS is used to specify the Device status value of the recipient device. This element’s value is determined as described in Appendix F: Device Status description table DTD Fragment Structure STATUS must appear once in the DEVICE Attributes None Example 2400
BBB. DESCRIPTION
DESCRIPTION is used to specify the Device status’s description. This actually the description as mentioned in Appendix F: Device Status description table DTD Fragment Structure DESCRIPTION must appear once in the DEVICE
TeleMessage XML Interface
© 1999-2007 TeleMessage Ltd Page 38 of 63
Attributes None Example Call completed successfully
CCC. STATUS_DATE
STATUS_DATE is used to specify time the current status was given. DTD Fragment Structure STATUS_DATE may appear once in the DEVICE. The content of the tags should conform to the following format: yyyymmdd hh:mm:ss. Attributes None Example < STATUS_DATE > 20070322 15:14:58
DDD. ANSWER
ANSWER is used to contain the text of the message’s reply. DTD Fragment Structure ANSWER may appear once in the DEVICE Attributes None Example 1
TeleMessage XML Interface
© 1999-2007 TeleMessage Ltd Page 39 of 63
iii. XML transmitting directions
A. Purpose This section of the document describes the methods that should be used in order to transmit the XML (as described above) to TeleMessage servers.
B. HTTP POST The XML data should be posted to: http://xml.telemessage.com/partners/xmlMessage.jsp
Appendix A – Examples: Note: Indentation is included here only as a visual aid. Actual markup should not contain any such formatting. Note: Actual SYSTEM link to DTD will be provided upon implementation.
1. Simple Text Message enter your subject here
TeleMessage XML Interface
© 1999-2007 TeleMessage Ltd Page 40 of 63
enter your user name here enter your password here 0 enter your text here 16173190666 1.6
2. Message to multiple recipients enter your subject here enter your user name here enter your password here
TeleMessage XML Interface
© 1999-2007 TeleMessage Ltd Page 41 of 63
0 enter your text here 16173190666 16173190666 [email protected] 1.6
3. Message with different sender phone number enter your subject here enter your user name here enter your password here 16173190666
TeleMessage XML Interface
© 1999-2007 TeleMessage Ltd Page 42 of 63
0 enter your text here 16173190666 16173190666 [email protected] 1.6
4. Message with attachment enter your subject here enter your user name here enter your password here 0
TeleMessage XML Interface
© 1999-2007 TeleMessage Ltd Page 43 of 63
enter your text here 1 message.gif image/gif R0lGODlhEgASAMT/AP////X5r+rq6t7e3tra2s7Ozr29va2trZycnJSUlG9vb2tra2dnZ0ZGRjo6
OikpKSUlJ SEhIR0dHQA AAMDAwAAAAAAAAAA AAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAACH5BAEA ABQALAAAA AASABIAQAVbICWO ZFlOQZoeghpMhSnP1PQwn rso400BOwKAwGKMZRajAQXIIGCCIFOyX q05Hg4J2y 34jsehGHgK7AaqgUPxKiLTjwakoL q+qy57DZ93UxIKgYKDCglfYIhHIQA7
16173190666 1.6
5. Schedule Message enter your subject here 20040701 18:30:00 enter your user name here enter your password here
TeleMessage XML Interface
© 1999-2007 TeleMessage Ltd Page 44 of 63
0 enter your text here 16173190666 1.6
6. Message in other language enter your language id here enter your country id here enter your subject here enter your user name here enter your password here 0 enter your text (encoded to UTF-8) here
TeleMessage XML Interface
© 1999-2007 TeleMessage Ltd Page 45 of 63
16173190666 1.6
7. TeleMessage's Response to Partners Message (see Appendix B): 2151375 10021016319846517266385885 100 Message added successfully. Returned MessageID from db is
2151375 1.6
8. Partner’s Message Status Query : 2151375 10021016319846517266385885 1.6
9. Response Status Sent from TeleMessage to Partner (see Appendix C and F):
TeleMessage XML Interface
© 1999-2007 TeleMessage Ltd Page 46 of 63
2000 Message delivered successfully 2151565 30 972-3-9225252 Ext. 917 2401 Call was answered 20070321 15:54:50 1 1.6
Appendix B – Statuses to be used in MESSAGE_STATUS element: Note: This Appendix will be updated continuously
STATUS_ID STATUS_DESCRIPTION
100 STATUS_MSG_ACCEPTED
300 STATUS_USER_DOESNT_EXIST
301 STATUS_INVALID_PASSWORD
302 STATUS_COUNTRY_NOT_SUPPORTED
303 STATUS_MESSAGE_DEVICE_LIMIT_EXCEEDED
304 STATUS_MESSAGE_LIMIT_REACHED
305 STATUS_NOT_ENOUGH_CREDIT
306 STATUS_QUOTA_LIMIT_REACHED
307 STATUS_USER_CANNOT_FORWARD
TeleMessage XML Interface
© 1999-2007 TeleMessage Ltd Page 47 of 63
308 STATUS_USER_CANCELED
309 STATUS_USER_SUSPENDED
310 STATUS_MESSAGE_MUST_CONTAIN_AT_LEAST_ONE_DESTINATION
311 STATUS_MESSAGES_INDEXES_NOT_SEQUENTIAL
400 STATUS_GENERAL_ERROR
401 STATUS_XML_VALIDATION_ERROR
Appendix C – Response Statuses: Note: This Appendix will be updated continuously
RESPONSE_ STATUS RESPONSE_STATUS_DESC
1000 DELIVERED
2000 SUCCESS
3000 PENDING
4000 FAILED
5000 CANCELED
Appendix D – Java Code:
1. Post XML This is a sample application that demonstrates how to send a message through TeleMessage's xml interface from your java code. The application posts XML file* (that represent a message) located on your local disk to our servers and get response about the sent message. The response includes message-id and message-key for tracing message delivery. import java.io.*; import java.io.FileInputStream; import javax.mail.internet.MimeUtility; import org.apache.commons.httpclient.HttpClient; import org.apache.commons.httpclient.methods.EntityEnclosingMethod; import org.apache.commons.httpclient.methods.PostMethod; public static void main (String[] args) {
try { // Get target URL String strURL = "http://xml.telemessage.com/partners/xmlMessage.jsp"; InputStream xmlin =null; *//Send xml file (read a local xml file and send it) String strXMLFilename = "add your file path here" ;
TeleMessage XML Interface
© 1999-2007 TeleMessage Ltd Page 48 of 63
File input = new File(strXMLFilename); xmlin = new FileInputStream(input); //Prepare HTTP post PostMethod post = new PostMethod(strURL); //Request content will be retrieved directly /// from the input stream post.setRequestBody(xmlin); //Per default, the request content needs to be buffered // in order to determine its length. // Request body buffering can be avoided when // = content length is explicitly specified // = chunk-encoding is used if (input.length() < Integer.MAX_VALUE) {
post.setRequestContentLength((int)input.length()); } else {
post.setRequestContentLength(EntityEnclosingMethod.CONTENT_LENGTH_CHUNKED); } //Specify content type and encoding // If content encoding is not explicitly specified // ISO-8859-1 is assumed post.setRequestHeader("Content-type", "text/xml; charset=ISO-8859-1"); //Get HTTP client HttpClient httpclient = new HttpClient(); //Execute request int result = httpclient.executeMethod(post); //Display status code System.out.println("Response status code: " + result); //Display response String responseStr = post.getResponseBodyAsString(); System.out.println("Response body: "); System.out.println(responseStr); //Release current connection to the connection pool once you are done post.releaseConnection();
} catch (Exception e) { System.out.println(e.getMessage());
} } * You can enter your string directly (instead of reading the file from your local disk) just replace the 3 lines under 'Send xml file' section to: String input = "add your string here"; xmlin = new ByteArrayInputStream(input.getBytes())
2. Message with attachment In order to send message with file attachment you should encode your file to base64 encoding. The following application demonstrate how to read a file located on your local disk, encode it to base64 and write the encoded file as a new file.
TeleMessage XML Interface
© 1999-2007 TeleMessage Ltd Page 49 of 63
import java.io.*; import javax.mail.internet.MimeUtility; public static void main(String[] args) {
//initialize input and output file name String strInputFileName = "enter file name (to encode) here"; String strOutputFileName = "enter output file name here"; rawFileToBase64 (strInputFileName,strOutputFileName);
} public static boolean rawFileToBase64 (String inFile, String outFile) {
try { // initialize inputFile FileInputStream fin = new FileInputStream(inFile); BufferedInputStream bis = new FBufferedInputStream(fin); // initialize outputFile FileOutputStream fos = new FileOutputStream(outFile); OutputStream os = MimeUtility.encode(fos,"base64"); BufferedOutputStream bos = new BufferedOutputStream(os); byte data[] = new new byte[1024]; int len; // read the buffered stream while(bis.available()>0) {
len = bis.read(data); bos.write(data,0,len);
} bos.close(); bis.close();
} catch (Exception e) { System.out.println("Unable to encode the contents of the request file."+ e);
} }
3. Message in other language In order to send message in other language the text encoding should be 'UTF-8'. The following application demonstrate how to read a file located on your local disk, encode it to 'UTF-8' and write the encoded file as a new file. import java.io.*; public static void main(String[] args) {
try { //encode inputFile to UTF-8 and write the encoded file to outputFile //assumption: the input file encoding is same as the file system default character-encoding, //To specify an encoding other than the default, you should change // 'System.getProperty("file.encoding")' to your file encoding.
TeleMessage XML Interface
© 1999-2007 TeleMessage Ltd Page 50 of 63
convertFileEncoding ( "input file path", System.getProperty("file.encoding"),"output file path", "UTF8");
} catch(Exception e) { System.out.println("Unable to encode the contents of the request file."+ e);
} } public static void convertFileEncoding (String sourcefile, String inEncoding,String outfile, String outEncoding) {
// initialize InputStream input = null; OutputStream out = null; try {
//Read sourcefile File infile = new File(sourcefile); input = new FileInputStream(infile); int bufLength = (int)infile.length(); byte[] bytes = new byte[bufLength]; input.read(bytes, 0, bufLength); String s = new String(bytes, inEncoding); //Write outfile out = new FileOutputStream(new File(outfile)); bytes = s.getBytes(outEncoding); out.write(bytes, 0, bytes.length);
} finaly { if (input != null)
input.close(); if (out != null)
out.close(); }
}
Appendix E – Visual Basic Code:
1. Post XML This is a sample module that demonstrates how to send a message through TeleMessage's xml interface from your visual basic code. The module posts XML string (that represents a message) to our servers and get response about the sent message. The response includes message-id and message-key for tracking message delivery. Note: The module references the MSXML library, therefore you should add reference to 'Microsoft XML, version 2.0'. Sub main()
Dim objHTTP As New MSXML.XMLHTTPRequest() Dim strMessage As String Dim strReturn As String
TeleMessage XML Interface
© 1999-2007 TeleMessage Ltd Page 51 of 63
Dim objReturn As New MSXML.DOMDocument() Dim dblTax As Double Dim strQuery As String 'Create the string to send strMessage = "enter your XML message here" 'Set up to post to our server objHTTP.open("post", "http://xml.telemessage.com/partners/xmlMessage.jsp", False) 'Set a standard XML header for the content-type objHTTP.setRequestHeader("Content-Type", "text/xml") 'Send the message objHTTP.send(strMessage) 'Get the return response strReturn = objHTTP.responseText 'Load the return response into a DOM objReturn.loadXML(strReturn) 'Write the return response Console.WriteLine(strReturn)
End Sub
Appendix F – PHP Language Code:
1. Post XML This is a sample application that demonstrates how to send a message through TeleMessage's xml interface from your PHP code. The application posts XML (that represent a message). The response includes message-id and message-key for tracing message delivery. Note:
1. PHP must be run with curl extension. For more information, visit http://www.php.net/manual/en/ref.curl.php
2. You can parse XML by using DOM extension in PHP5 (http://www.php.net/manual/en/ref.dom.php) and DOMxml extension in PHP4 (http://www.php.net/manual/en/ref.domxml.php).
TeleMessage XML Interface
© 1999-2007 TeleMessage Ltd Page 52 of 63
//creating and initiating curl $ch = curl_init(); //setting curl/http headers curl_setopt($ch, CURLOPT_POST,1); curl_setopt($ch, CURLOPT_POSTFIELDS,$str); curl_setopt($ch, CURLOPT_URL," http://xml.telemessage.com/partners/xmlMessage.jsp "); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); //executing http request and getting response. $postResult will contain response xml from TeleMessage. $postResult = curl_exec($ch); if (curl_errno($ch)) { // you can return null for both PHP4 and PHP5
return null; /* * for PHP5 you can throw Exception: * throw new Exception("Error while sending"); */ } curl_close($ch); return $postResult;
} ?>
Appendix G – ISO Language Code: These codes are the lower-case two-letter codes as defined by ISO-639 http://www1.ics.uci.edu/pub/ietf/http/related/iso639.txt
aa Afar mi Maori
ab Abkhazian mk Macedonian
af Afrikaans ml Malayalam
am Amharic mn Mongolian
ar Arabic mo Moldavian
as Assamese mr Marathi
ay Aymara ms Malay
az Azerbaijani mt Maltese
ba Bashkir my Burmese
be Byelorussian na Nauru
bg Bulgarian ne Nepali
bh Bihari nl Dutch
bi Bislama no Norwegian
bn Bengali; Bangla oc Occitan
bo Tibetan om (Afan) Oromo
br Breton or Oriya
ca Catalan pa Punjabi
TeleMessage XML Interface
© 1999-2007 TeleMessage Ltd Page 53 of 63
co Corsican pl Polish
cs Czech ps Pashto, Pushto
cy Welsh pt Portuguese
da Danish qu Quechua
de German rm Rhaeto-Romance
dz Bhutani rn Kirundi
el Greek ro Romanian
en English ru Russian
eo Esperanto rw Kinyarwanda
es Spanish sa Sanskrit
et Estonian sd Sindhi
eu Basque sg Sangho
fa Persian sh Serbo-Croatian
fi Finnish si Sinhalese
fj Fiji sk Slovak
fo Faroese sl Slovenian
fr French sm Samoan
fy Frisian sn Shona
ga Irish so Somali
gd Scots Gaelic sq Albanian
gl Galician sr Serbian
gn Guarani ss Siswati
gu Gujarati st Sesotho
ha Hausa su Sundanese
he Hebrew (formerly iw) sv Swedish
hi Hindi sw Swahili
hr Croatian ta Tamil
hu Hungarian te Telugu
hy Armenian tg Tajik
ia Interlingua th Thai
id Indonesian (formerly in) ti Tigrinya
ie Interlingue tk Turkmen
ik Inupiak tl Tagalog
is Icelandic tn Setswana
it Italian to Tonga
iu Inuktitut tr Turkish
ja Japanese ts Tsonga
jw Javanese tt Tatar
ka Georgian tw Twi
kk Kazakh ug Uighur
kl Greenlandic uk Ukrainian
km Cambodian ur Urdu
kn Kannada uz Uzbek
ko Korean vi Vietnamese
ks Kashmiri vo Volapuk
ku Kurdish wo Wolof
TeleMessage XML Interface
© 1999-2007 TeleMessage Ltd Page 54 of 63
ky Kirghiz xh Xhosa
la Latin yi Yiddish (formerly ji)
ln Lingala yo Yoruba
lo Laothian za Zhuang
lt Lithuanian zh Chinese
lv Latvian, Lettish zu Zulu
mg Malagasy
Appendix H – ISO Country Code: These codes are the upper-case two-letter codes as defined by ISO-3166. http://userpage.chemie.fu-berlin.de/diverse/doc/ISO_3166.html
Country A 2 A 3 Number
AFGHANISTAN AF AFG 4
ALBANIA AL ALB 8
ALGERIA DZ DZA 12
AMERICAN SAMOA AS ASM 16
ANDORRA AD AND 20
ANGOLA AO AGO 24
ANGUILLA AI AIA 660
ANTARCTICA AQ ATA 10
ANTIGUA AND BARBUDA AG ATG 28
ARGENTINA AR ARG 32
ARMENIA AM ARM 51
ARUBA AW ABW 533
AUSTRALIA AU AUS 36
AUSTRIA AT AUT 40
AZERBAIJAN AZ AZE 31
BAHAMAS BS BHS 44
BAHRAIN BH BHR 48
BANGLADESH BD BGD 50
BARBADOS BB BRB 52
BELARUS BY BLR 112
BELGIUM BE BEL 56
BELIZE BZ BLZ 84
BENIN BJ BEN 204
BERMUDA BM BMU 60
BHUTAN BT BTN 64
BOLIVIA BO BOL 68
BOSNIA AND HERZEGOWINA BA BIH 70
BOTSWANA BW BWA 72
BOUVET ISLAND BV BVT 74
BRAZIL BR BRA 76
TeleMessage XML Interface
© 1999-2007 TeleMessage Ltd Page 55 of 63
BRITISH INDIAN OCEAN TERRITORY IO IOT 86
BRUNEI DARUSSALAM BN BRN 96
BULGARIA BG BGR 100
BURKINA FASO BF BFA 854
BURUNDI BI BDI 108
CAMBODIA KH KHM 116
CAMEROON CM CMR 120
CANADA CA CAN 124
CAPE VERDE CV CPV 132
CAYMAN ISLANDS KY CYM 136
CENTRAL AFRICAN REPUBLIC CF CAF 140
CHAD TD TCD 148
CHILE CL CHL 152
CHINA CN CHN 156
CHRISTMAS ISLAND CX CXR 162
COCOS (KEELING) ISLANDS CC CCK 166
COLOMBIA CO COL 170
COMOROS KM COM 174
CONGO CG COG 178
COOK ISLANDS CK COK 184
COSTA RICA CR CRI 188
COTE D'IVOIRE CI CIV 384
CROATIA (local name: Hrvatska) HR HRV 191
CUBA CU CUB 192
CYPRUS CY CYP 196
CZECH REPUBLIC CZ CZE 203
DENMARK DK DNK 208
DJIBOUTI DJ DJI 262
DOMINICA DM DMA 212
DOMINICAN REPUBLIC DO DOM 214
EAST TIMOR TP TMP 626
ECUADOR EC ECU 218
EGYPT EG EGY 818
EL SALVADOR SV SLV 222
EQUATORIAL GUINEA GQ GNQ 226
ERITREA ER ERI 232
ESTONIA EE EST 233
ETHIOPIA ET ETH 231
FALKLAND ISLANDS (MALVINAS) FK FLK 238
FAROE ISLANDS FO FRO 234
FIJI FJ FJI 242
FINLAND FI FIN 246
FRANCE FR FRA 250
FRANCE, METROPOLITAN FX FXX 249
FRENCH GUIANA GF GUF 254
TeleMessage XML Interface
© 1999-2007 TeleMessage Ltd Page 56 of 63
FRENCH POLYNESIA PF PYF 258
FRENCH SOUTHERN TERRITORIES TF ATF 260
GABON GA GAB 266
GAMBIA GM GMB 270
GEORGIA GE GEO 268
GERMANY DE DEU 276
GHANA GH GHA 288
GIBRALTAR GI GIB 292
GREECE GR GRC 300
GREENLAND GL GRL 304
GRENADA GD GRD 308
GUADELOUPE GP GLP 312
GUAM GU GUM 316
GUATEMALA GT GTM 320
GUINEA GN GIN 324
GUINEA-BISSAU GW GNB 624
GUYANA GY GUY 328
HAITI HT HTI 332
HEARD AND MC DONALD ISLANDS HM HMD 334
HONDURAS HN HND 340
HONG KONG HK HKG 344
HUNGARY HU HUN 348
ICELAND IS ISL 352
INDIA IN IND 356
INDONESIA ID IDN 360
IRAN (ISLAMIC REPUBLIC OF) IR IRN 364
IRAQ IQ IRQ 368
IRELAND IE IRL 372
ISRAEL IL ISR 376
ITALY IT ITA 380
JAMAICA JM JAM 388
JAPAN JP JPN 392
JORDAN JO JOR 400
KAZAKHSTAN KZ KAZ 398
KENYA KE KEN 404
KIRIBATI KI KIR 296
KOREA, DEMOCRATIC PEOPLE'S REPUBLIC OF KP PRK 408
KOREA, REPUBLIC OF KR KOR 410
KUWAIT KW KWT 414
KYRGYZSTAN KG KGZ 417
LAO PEOPLE'S DEMOCRATIC REPUBLIC LA LAO 418
LATVIA LV LVA 428
LEBANON LB LBN 422
LESOTHO LS LSO 426
LIBERIA LR LBR 430
TeleMessage XML Interface
© 1999-2007 TeleMessage Ltd Page 57 of 63
LIBYAN ARAB JAMAHIRIYA LY LBY 434
LIECHTENSTEIN LI LIE 438
LITHUANIA LT LTU 440
LUXEMBOURG LU LUX 442
MACAU MO MAC 446
MACEDONIA, THE FORMER YUGOSLAV REPUBLIC OF MK MKD 807
MADAGASCAR MG MDG 450
MALAWI MW MWI 454
MALAYSIA MY MYS 458
MALDIVES MV MDV 462
MALI ML MLI 466
MALTA MT MLT 470
MARSHALL ISLANDS MH MHL 584
MARTINIQUE MQ MTQ 474
MAURITANIA MR MRT 478
MAURITIUS MU MUS 480
MAYOTTE YT MYT 175
MEXICO MX MEX 484
MICRONESIA, FEDERATED STATES OF FM FSM 583
MOLDOVA, REPUBLIC OF MD MDA 498
MONACO MC MCO 492
MONGOLIA MN MNG 496
MONTSERRAT MS MSR 500
MOROCCO MA MAR 504
MOZAMBIQUE MZ MOZ 508
MYANMAR MM MMR 104
NAMIBIA NA NAM 516
NAURU NR NRU 520
NEPAL NP NPL 524
NETHERLANDS NL NLD 528
NETHERLANDS ANTILLES AN ANT 530
NEW CALEDONIA NC NCL 540
NEW ZEALAND NZ NZL 554
NICARAGUA NI NIC 558
NIGER NE NER 562
NIGERIA NG NGA 566
NIUE NU NIU 570
NORFOLK ISLAND NF NFK 574
NORTHERN MARIANA ISLANDS MP MNP 580
NORWAY NO NOR 578
OMAN OM OMN 512
PAKISTAN PK PAK 586
PALAU PW PLW 585
PANAMA PA PAN 591
TeleMessage XML Interface
© 1999-2007 TeleMessage Ltd Page 58 of 63
PAPUA NEW GUINEA PG PNG 598
PARAGUAY PY PRY 600
PERU PE PER 604
PHILIPPINES PH PHL 608
PITCAIRN PN PCN 612
POLAND PL POL 616
PORTUGAL PT PRT 620
PUERTO RICO PR PRI 630
QATAR QA QAT 634
REUNION RE REU 638
ROMANIA RO ROM 642
RUSSIAN FEDERATION RU RUS 643
RWANDA RW RWA 646
SAINT KITTS AND NEVIS KN KNA 659
SAINT LUCIA LC LCA 662
SAINT VINCENT AND THE GRENADINES VC VCT 670
SAMOA WS WSM 882
SAN MARINO SM SMR 674
SAO TOME AND PRINCIPE ST STP 678
SAUDI ARABIA SA SAU 682
SENEGAL SN SEN 686
SEYCHELLES SC SYC 690
SIERRA LEONE SL SLE 694
SINGAPORE SG SGP 702
SLOVAKIA (Slovak Republic) SK SVK 703
SLOVENIA SI SVN 705
SOLOMON ISLANDS SB SLB 90
SOMALIA SO SOM 706
SOUTH AFRICA ZA ZAF 710
SOUTH GEORGIA AND THE SOUTH SANDWICH ISLANDS GS SGS 239
SPAIN ES ESP 724
SRI LANKA LK LKA 144
ST. HELENA SH SHN 654
ST. PIERRE AND MIQUELON PM SPM 666
SUDAN SD SDN 736
SURINAME SR SUR 740
SVALBARD AND JAN MAYEN ISLANDS SJ SJM 744
SWAZILAND SZ SWZ 748
SWEDEN SE SWE 752
SWITZERLAND CH CHE 756
SYRIAN ARAB REPUBLIC SY SYR 760
TAIWAN TW TWN 158
TAJIKISTAN TJ TJK 762
TANZANIA, UNITED REPUBLIC OF TZ TZA 834
TeleMessage XML Interface
© 1999-2007 TeleMessage Ltd Page 59 of 63
THAILAND TH THA 764
TOGO TG TGO 768
TOKELAU TK TKL 772
TONGA TO TON 776
TRINIDAD AND TOBAGO TT TTO 780
TUNISIA TN TUN 788
TURKEY TR TUR 792
TURKMENISTAN TM TKM 795
TURKS AND CAICOS ISLANDS TC TCA 796
TUVALU TV TUV 798
UGANDA UG UGA 800
UKRAINE UA UKR 804
UNITED ARAB EMIRATES AE ARE 784
UNITED KINGDOM GB GBR 826
UNITED STATES US USA 840
UNITED STATES MINOR OUTLYING ISLANDS UM UMI 581
URUGUAY UY URY 858
UZBEKISTAN UZ UZB 860
VANUATU VU VUT 548
VATICAN CITY STATE (HOLY SEE) VA VAT 336
VENEZUELA VE VEN 862
VIET NAM VN VNM 704
VIRGIN ISLANDS (BRITISH) VG VGB 92
VIRGIN ISLANDS (U.S.) VI VIR 850
WALLIS AND FUTUNA ISLANDS WF WLF 876
WESTERN SAHARA EH ESH 732
YEMEN YE YEM 887
YUGOSLAVIA YU YUG 891
ZAIRE ZR ZAR 180
ZAMBIA ZM ZMB 894
ZIMBABWE ZW ZWE 716
TeleMessage XML Interface
© 1999-2007 TeleMessage Ltd Page 60 of 63
Appendix I – Device Status description table
Status Description Status Description
0 Message not delivered yet 2417 Call completed successfully
1 Message re-scheduled by the system 2418 Call completed successfully
1000 Message has been sent 2500 SMS was delivered with confirmation
1100 Email was delivered 2501 SMS was delivered to handset
1200 Fax has been sent 2500 MMS was delivered
1400 Call has been made 3000 Message delivery in progress
1401 Not confirmed by recipient 3001 Message delivery in progress: No MessageSender Server available
1402 Call reached a voice mail - message left on voice mail system
3002 Message delivery in progress: MessageSender was busy
1500 SMS successfully sent 3003 Device is about to be re-sent
1501 SMS successfully sent 3100 Message Delivery failed
1502 Mobile not reachable or it's memory capacity exceeded (SMS may not be delivered)
3200 Fax delivery in progress
1503 Message partially sent due to insufficient credit
3400 Message delivery in progress
1504 SMS successfully sent 3500 SMS is being delivered
1700 MMS successfully sent 3600 Message Delivery failed
1701 MMS was Delivered partially 4000 Message delivery failed
1702 MMS was Delivered forwarded 4005 Sending of message cancelled by user
2000 Message delivered successfully 4010 Device was blocked by recipient
2100 Email successfully sent 4011 Device was blocked by recipient
2200 Fax delivered successfully 4012 Area code is blocked by the system
2400 Call completed successfully 4013 Country is not supported
2401 Call was answered 4014 Device was blocked in a range of hours by recipient
TeleMessage XML Interface
© 1999-2007 TeleMessage Ltd Page 61 of 63
2402 Call was diverted, most probably to answering machine
4022 Device usage limit reached
2403 Call reached extension, but there was no answer
4023 Device usage restricted
2412 Call completed successfully 4024 Sending to this device is not allowed because it is not free
2415 Call completed successfully 4031 Message delivery failed: No Processor
2416 Call completed successfully 4032 Message delivery failed: No Message Dispatcher available
Status Description Status Description
4033 Unsupported destination (Message delivery failed)
4402 Call was not answered (Message not delivered)
4040 All retries to deliver the message failed 4403 Call reached a no dial tone signal (Message not delivered)
4100 Email delivery failed 4404 Call was not answered (Message not delivered)
4101 Email delivery failed (Wrong sender email address)
4405 Call was not answered (Message not delivered)
4102 Email delivery failed (Wrong recipient email address)
4406 Recipient hung up in middle of call (Message not delivered)
4103 Email delivery failed 4407 Call reached a fax machine tone (Message not delivered)
4104 Email delivery failed (Nondeliverable mail)
4408 Failed to send message (the administrator will be notified)
4200 Attempts to send fax was unsuccessful 4409 Call encountered an error (Message not delivered)
4201 Call reached no dialtone (Fax message was not delivered)
4410 Invalid phone number (Message not delivered)
4202 Call reached a line busy tone (Fax message was not delivered)
4411 Area code or phone number are blocked for calls (Message not delivered)
4203 Call was not answered by fax machine (Fax me