Ozeki Message Server 6

SMS API for JAVA developers

The following example gives you detailed instructions on how you can send a WAP Push SMS messages from Java. The example uses HTTP Client functionality to pass the outgoing messages to the built in HTTP server of Ozeki Message Server. In the example we assume, that Ozeki Message Server is already installed and configured. A WAP push message contains a description of a WAP page and an URL that points to it.

Ozeki Message server can also be used to send text messages and various binary SMSes such as vCard and vCalendar messages, Operator Logos and Ringtones. All you have to do is change the messageType field and the message content in this example. A list of supported message types can be found on the following URL: https://ozeki.hu/p_488-sms-message-types.html.

To send a WAP push message we use the HTTP client library of Apache.org. First you need to download this library:

Step 1. - download the apache HTTP client library

Go to the following webpage:
http://apache.mirrors.crysys.hit.bme.hu/dist/httpcomponents/commons-httpclient/binary/commons-httpclient-3.1.zip, and download version 3.1.

After you have downloaded the file (commons-httpclient-3.1-src.zip) unzip it! The unzip will create the following jar file, that contains the HTTP client utilities: commons-httpclient-3.1.jar

Setp 2 - set the CLASSPATH to have access to the functions stored in this jar.

SET CLASSPATH=C:/tmp/commons-httpclient-3.1/commons-httpclient-3.1.jar

Step 3 - create a .java source file, that will connect to Ozeki Message Server and will post a message.


import org.apache.commons.httpclient.*;
import org.apache.commons.httpclient.methods.*;

public class PostExample {
 public static void main( String[] args ) {
   String url = "";
   String wapPush= " <si>"+
                   "    <indication href=\"http://wap.yahoo.com/\" action=\"signal-high\">"+
                   "        A WAP Push message, that sends the browser to wap.yahoo.com."+
                   "    </indication>"+
   try {
    HttpClient client = new HttpClient();
    PostMethod method = new PostMethod( url );

  // Configure the form parameters
  method.addParameter( "login", "admin" );
  method.addParameter( "password", "abc123" );
  // method.addParameter( "operator", "Vodafone" );
  method.addParameter( "action", "sendMessage" );
  method.addParameter( "messageType", "SMS:WAPPUSH:application/vnd.wap.sic" );
  method.addParameter( "recepient", "+36205222245" );
  method.addParameter( "messageData", wapPush );

  // Execute the POST method
    int statusCode = client.executeMethod( method );
    if( statusCode != -1 ) {
      String contents = method.getResponseBodyAsString();
      System.out.println( contents );
   catch( Exception e ) {

Step 4 - compile the file

javac PostExample.java

Step 5 - send the WAP push message

java PostExample.java

More information