This guide explains how to send SMS text messages to mobile phones
form Java using HTTP requests. It includes an explanation and a sample code
you can use in your application.
Introduction
HTTP is the simplest method to send data from one application to another. Java
has native method calls to submit HTTP requests. This means that HTTP is a good
choice to send SMS text messages to mobile phones. If you operate an SMS gateway
in your network, for example the Ozeki NG SMS Gateway, you can pass SMS messages
to it using HTTP GET or HTTP POST method calls (Figure 1).
Figure 1 - How to send SMS messages from JAVA through HTTP.
If you take look at the Figure 1, you will see, that to be able to communicate
with mobile phones, you need to pass your messages to the HTTP Gateway. The
HTTP Gateway has a built in webserver, that provides an
HTTP SMS API,
that makes it possible to submit messages. After your messages arrive to the
SMS Gateway, they will be sent to the mobile network through one of the channels
you have configured previously. For example, the SMS gateway can
operate a mobile phone attached to the PC with a data cable and can use
this mobile phone to send
and receive your messages. It can also send the messages through the Internet to
an SMS service provider.
If you are a JAVA developer, you should already have
the Java SE Development Kit installed on your computer and you probably already
use a development tool, such as Eclipse IDE. To be able to send SMS messages,
you
need to define a new JAVA class, and past the source code bellow into it.
To be able to submit messages, you also need to
install
and configure the Ozeki NG SMS Gateway software. In Ozeki NG SMS Gateway you
should configure an HTTP Server user. When you create an HTTP Server user,
you will provide a username and password. You can change the values of the
username and password variables in the source code bellow to the values you have
provided when you have defined the HTTP Server user in Ozeki NG SMS Gateway.
Source code sample
Feel free to use and modify this source code sample!