Quick Start on ‘How to create your own SMS Application’

This article, guides you to develop a SMS application using Dev Space APIs (powered by hSenid Mobile) and to test the developed application using the Dev Space simulator.

Dev Space gives you the flexibility of developing your own application from scratch as well as to develop your application on top of an already available sample application. Dev Space offers you a selection of sample applications on top of which you can create your own application making the necessary changes.

In this exercise, we will be using a sample application already available in Dev Space, to develop  an application for a coffee-shop where customers can send reviews/feedback of their coffee-shop experience. Let’s look at the steps you need to follow.



To get started you need to first visit Dev Space  and register yourself as a developer where you can find all the resources in the Dev Kit  which includes

  • API Guides
  • Sample Applications
  • Simulator to test your application

Note: The Tools used in this tutorial are,

1)     JDK 1.6

2)     IDE – Eclipse Kepler



Upon registering in Dev Space and downloading the necessary tools, let’s set up the development environment for our application. Here’s what you need to do to set up the project in Eclipse.

  • Create a simple web project

Go to File > New >  Dynamic Web Project

  • Name the Project as CoffeeShopFeedback.
    • Import Libraries

    Once you download the sample applications and the library from Dev space,import them to your created Project.

    • sdp.app.api-<latest-version>.jar [Ex –sdp.app.api-1.0.144.jar]
    • gson-1.7.1.jar

To import Libraries to project :

1)     Right click on the Project > Click Properties

2)    Select java build path > Add external libraries

Now we are almost done setting up the development environment. Time to move on to the coding…



The Dev Space SMS Interface allows applications to send and receive SMS messages using a HTTP-based API. Following are the key areas we will walk you through in this tutorial.

1)     Handle SMS Receiving – handling SMS messages sent to the application by customers.

2)     Handle SMS Sending –Send out a SMS message from the application to customers.


3.1  Handle SMS Receiving

We will be creating a “FeedbackListener” class to get started on handling the SMS receiving part of the app,. In order to capture a receiving SMS we need to implement “MoSmsListener” interface where we need to override the following two methods.



When customer sends a SMS to the application, onReceivedSms() method will trigger with the MoSmsReq object which contains the sent message, Sent Address and etc.. (For further details, please visit SMS API Documentation )

public void onReceivedSms(MoSmsReq moSmsReq) {

String message = moSmsReq.getMessage();
String sourceAddress = moSmsReq.getSourceAddress();

// Store Received Feedback
addFeedback(sourceAddress, message);

FeedbackService is used to store the received feedback message and the source address (Sender Address) throughsubscriberFeedback Map.

public class FeedbackService {

private static final Map<String, String> subscriberFeedback = new HashMap<String, String>();

public static void addFeedback(String subscriberId, String message) {
subscriberFeedback.put(subscriberId, message);

public static Map<String, String> getFeedback() {
return subscriberFeedback;

Now that we know how to handle receiving SMS’s, why not reply back by thanking for the given feedback .For that, we can use the Dev Space Send SMS API to send the reply easily.


3.2 Handle SMS Sending

This service allows the coffee shop owner to send SMS to one or more terminals (phones or any SMS-enabled device) from the application.

private void sendResponse(MoSmsReq moSmsReq) {

try {

MtSmsReqmtSmsReq = new MtSmsReq();

mtSmsReq.setMessage("Thank you for your feedback, Hope to see you again");

SmsRequestSenderrequestSender = new SmsRequestSender(new URL("http://localhost:7000/sms/send"));
MtSmsRespsmsResp = requestSender.sendSmsRequest(mtSmsReq)

System.out.println("Response " + smsResp);
} catch (SdpException e) {
System.err.println("Error " + e);
} catch (MalformedURLException e) {
System.err.println("Error " + e);


As could be seen in the above code snippet we have to create “MtSmsReq” object in order to store parameters which we need to send as follows.

setMessage()   – Set Message you want send  out. Ex -: “Thank you for your feedback, Hope to see you again”

setApplicationID() – Set Application ID as given when your application was provisioned

setPassword() – Set Password given when the application was provisioned

setDestinationAddresses() – Set List of destination addresses to which you want to send the message. You need to add at least one address in order to send the message

For the example in discussion, we will send a message to the received number. For further details on the parameters to be set – Please visit http://devspace.hsenidmobile.com/guide/sms-api.php#SMS

In order to send the created MtSmsReq object we need to create the sender object “SmsRequestSender” with the sender URL that specifies the destination of the MtSmsReq.

In this example, the destination will be the simulator URL – http://localhost:7000/sms/send. Specific URL will be provided for the live configurations.

We can capture the response through “MtSmsResp” which includes the statusCode, statusDetails, etc..

(Further details – check SMS API )

Here you can filter out the success response through the “S1000” status code where your request is successfully processed.

There will be specific error scenarios you may have to handle if you have any errors in your request. For example if you result in “E1313” error code, it indicates an authentication failure of your application where you have to check your application Id or the password and retry. You may find the other error codes and the description in –http://devspace.hsenidmobile.com/guide/sms-api.php#SMS for the respective services.

Some of the error codes and their descriptions:

You need to make sure you handle “SdpException” and “MalformedURLException” in order to prevent any unexpected failures in the application.

Now we have completed developing the SMS Message Sending and Receiving services. Since we have created this as a web application, we need to configure the servlet in the web xml to receive the SMS to our FeedbackListener class andMoSmsReceiver through our API class as in the following code snippet.


Then you can configure any mapping URL to map your created servlet as following.


View received Feedback

We can create a simple jsp – index.jsp in order to view all the feedback on a table along with the respective subscriber Id.

Now that we have completed  developing our Coffee-shop SMS Application, we can move on to testing.


First, we need to deploy our application in Tomcat. We can start tomcat through Eclipse as follows.

Initially, the URL http://localhost:8080/CoffeeShopFeedback/ will direct you to an empty feedback table until a feedback is received.

The Dev Space simulator could be used in order to simulate feedback generated from a phone.

If you have downloaded the Simulator from Dev Space, you can start the simulator as follows.

Go to your downloaded Dev Space Simulator directory

cd /Dev Space-Simulator/bin

Execute the following commands

on Linux

./sdp-simulator console

on Windows

sdp-simulator.bat console

Upon starting the simulator you can view the simulator through


For further details about the simulator Please visit Simulator guide in http://devspace.hsenidmobile.com/guide/sms-sdk.php


The URL in the simulator represents the application hosted URL in the simulator, so as per our example it will be –



The test data:

Once the test feedback message is sent to the application through the simulator a message will be received from application on to the simulator.


Message Sent to Application

Message Sent to Customer

Let’s check the feedback received to our application through our web page.


In order to deploy with the Telco, you need to provision your application. This means you have to register the application with the Telco to make it go live. In provisioning , you will type in the basic details of the app such as app name and app details in a web based module.

After provisioning you will get the App id and password which will be used in your code. Drop a mail to devspace@hsenidmobile.com for provisioning.

That’s it!  You have built your first SMS application using the Dev Space APIs.

Yet another coding session which introduces a new Telco API awaits.

Happy Coding! icon smile Quick Start on ‘How to create your own SMS Application’


Blog by Randula Wijesinghe : Software Engineer – hSenid Mobile

Recent Posts