The Wireless Messaging API (JSR-205) specification allows you to compose, send, and receive SMS and MMS messages through Java™ applications (MIDlets).
The Wireless Messaging API (WM API) is based on the Generic Connection Framework (GCF). The GCF
is defined in the javax.microedition.io
package
of the Connected Limited Device Configuration (CLDC) 1.0 specification.
The package defines an extensible framework for connections and supports
input/output and networking functionality in Java Platform Micro Edition
profiles.
Representation of a message
A message can be thought of as having an address part and a data
part. A message is represented by a class that implements the interface
defined for messages in the WM API 2.0. This interface provides methods
that are common for all messages. In the javax.wireless.messaging
package, the base interface that is implemented by all messages
is named Message
. It provides methods for addresses
and timestamps.
For the data part of the message, the WM API 2.0 is designed to
handle text, binary and multipart messages. These are represented
by three subinterfaces of Message
: TextMessage
, BinaryMessage
and MultipartMessage
. These subinterfaces provide ways to
manipulate the payload of the message as Strings
, byte arrays and message parts, respectively.
Other subinterfaces of Message
can be defined
for message payloads which are neither pure text nor pure binary.
It is also possible to create further subinterfaces of TextMessage
, BinaryMessage
and MultipartMessage
for possible protocol-specific features.
Sending and receiving messages
As defined by the Generic Connection Framework, the message sending
and receiving functionality is implemented by a Connection
interface, in WM API 2.0's case, MessageConnection
. To make a connection, the application obtains an object implementing
the MessageConnection
from the Connector
class by providing a URL connection string that identifies the address.
For more information about the sending and receiving of messages, see the Wireless Messaging API (JSR-205) specification.
Permissions for Series 40 Platforms
Permissions must be granted to open a connection and to send and receive messages, as specified in the WM API 2.0 specification. Separate permissions are provided for the SMS and MMS messaging. If the permission is not granted, then Connector.open must throw a SecurityException.
If the application attempts to send or receive a message to a restricted port number, then a SecurityException is thrown. The table below shows the port numbers that are restricted to SMS messages:
Port number | Description |
2805 | WAP WTA secure connection-less session service |
2923 | WAP WTA secure session service |
2948 | WAP Push connectionless session service (client side) |
2949 | WAP Push secure connectionless session service (client side) |
5502 | Service Card reader |
5503 | Internet access configuration reader |
5508 | Dynamic Menu Control Protocol |
5511 | Message Access Protocol |
5512 | Simple Email Notification |
9200 | WAP connectionless session service |
9201 | WAP session service |
9202 | WAP secure connectionless session service |
9203 | WAP secure session service |
9207 | WAP vCal Secure |
49996 | SyncML OTA configuration |
49999 | WAP OTA configuration |
For more information about the permissions in WM API 2.0, see Appendix E of Wireless Messaging API (JSR-205) specification.