sms software
About UsHow to buyDownloadSitemapContact Us
 
Our ProductsServicesNews & EventsOnline DemoCustomer SupportClient/UsersPartner Program
 
Documentation/Manuals
Tutorial
Faq
Forum(new)
Mailing List
SMS Message Centres(SMSCs) Worldwide
GSM Phone Number Series
Url Encode Chart
GSM Operator Code
Charset For Sending SMS In Different Language VIA Web Form
7 Bit Default Alphabet
Useful Downloads/Links
= =
 
 

Java Examples to Send SMS, Receive SMS.

Introduction

This tutorial demostrates how it is possible to write Java applications to send and receive SMS using VisualGSM Enterprise Server.

We shall go through 2 methods which you can use to send SMS through VisualGSM Enterprise:

1). Execute an SQL statement to insert the new message into VisualGSM LOGLOG table.

2). Issue an HTTP GET to VisualGSM Enterprise CSEND web API.

VisualGSM Enterprise can forward received SMS messages to your Java application via HTTP GET.

 
Software Requirement

1). VisualGSM Enterprise Server (SMS Gateway)
2). JDK 6 (you may use higher versions)
3). Netbeans IDE with JavaEE/Glassfish
4). Sample Java NetBean Project

 
Procedure
Example 1:- Making a Java class send SMS by executing an SQL statement to insert the new message into VisualGSM LOGLOG table.
1. Install VisualGSM Enterprise Server..

If you have not installed VisualGSM Enterprise Server, you can download the installers from this link (VisualGSM SMS Gateway Download). Refer to the "Quick Start Checklist" on how to configure VisualGSM Enterprise Server.
2. Install JDK 6 (minimum) and NetBeans with JEE features.

First of all, you should download and install JDK 6 (minimum) and NetBeans with Glassfish and JEE features, if you have not done so. You can find the links to the installers in under Software Requirements as shown above.
3. Open DBCode project in NetBeans.

Run NetBeans from Windows Start Menu, open the project DBCode (path: \java-samples\DBCode\).

If you encounter reference problems, you can right click the project in the projects window and choose "Resolve Reference Problems" to find the missing resources. The missing database libraries can be found under \java-samples\DBCode\ subfolder.

There are 3 Java classes, (MSSQLCode.java, MySQLCode.java, OracleCode.java), select the class which corresponds to the database you are using.

Change the value of connection URL, user and password values in the class you have selected.

For example, for MSSQLCode.java:

//vars for connection

String url = "jdbc:sqlserver://127.0.0.1:1433;databaseName=VGSMDB"; //replace 127.0.0.1 with SQL Server ip address

String user = "sa"; //replace with sql server user

String pass = "password"; //replace with sql server user password



Once you have opened the class in NetBeans, you can run the class with Shift+F6.

4. Start VisualGSM Service.

Start VisualGSM Service using the "Start" button on VisualGSM Enterprise Manager.

Note:- If VisualGSM service does not start, refer to the returned message and check your setup. Refer to the next section, troubleshooting.

Proceed with live SMS testing (see Step 3). Refer to the sms server log file for testing details.

 
 
Example 2:- Using a JSP to send SMS by issuing an HTTP GET to VisualGSM Enterprise CSEND web API.

1. Install VisualGSM Enterprise Server.

If you have not installed VisualGSM Enterprise Server, you can download the installers from this link (VisualGSM SMS Gateway Download). Refer to the "Quick Start Checklist" on how to configure VisualGSM Enterprise Server.

2. Install JDK 6 (minimum) and NetBeans with JEE features.

First of all, you should download and install JDK 6 (minimum) and NetBeans with Glassfish and JEE features, if you have not done so. You can find the links to the installers in under Software Requirements as shown above.

3. Open HTTPRequestTest project in NetBeans.

Run NetBeans from Windows Start Menu, open the project DBCode (path: \java-samples\HTTPRequestTest\).

Open index.jsp, and change the value of String url.

For example:

String url = "http://127.0.0.1/cgi-bin/csend.exe";


You can run the index.jsp by pressing Shift+F6.

4. Start VisualGSM Service.

Start VisualGSM Service using the "Start" button on VisualGSM Enterprise Manager.

Note:- If VisualGSM service does not start, refer to the returned message and check your setup. Refer to the next section, troubleshooting.

Proceed with live SMS testing (see Step 3). Refer to the sms server log file for testing details.

 
 
Example 3:- Setting up VisualGSM Enterprise to forward received SMS messages to your Java application via HTTP GET.

1. Install VisualGSM Enterprise Server.

If you have not installed VisualGSM Enterprise Server, you can download the installers from this link (VisualGSM SMS Gateway Download). Refer to the "Quick Start Checklist" on how to configure VisualGSM Enterprise Server.

2. Install JDK 6 (minimum) and NetBeans with JEE features.

First of all, you should download and install JDK 6 (minimum) and NetBeans with Glassfish and JEE features, if you have not done so. You can find the links to the installers in under Software Requirements as shown above.

3. Open HTTPRequestTest project in NetBeans.

Run NetBeans from Windows Start Menu, open the project DBCode (path: \java-samples\HTTPRequestTest\).

Open sms2java.jsp, and amend the code as required.

Then run sms2java.jsp by pressing Shift+F6.

4. Following that, create the HTTP type keyword to forward received SMSes to sms2java.jsp.

Note: If you have not installed VisualGSM Enterprise Server, you can download the installers from this link (VisualGSM SMS Gateway). Refer to the "Quick Start Checklist" on how to configure VisualGSM Enterprise Server.

At this point, do not close NetBeans.

Run VisualGSM Enterprise Manager, and click on "Keyword" tab.

Scroll through the table and select the keyword with the name "NOKEYWORD". Click on "Edit ", change the Type to "HTTP URL" (refer to the below screen capture for details).

Set URL as:



Set Parameter as:



Click on the TEST button to simulate the Keyword Action.



5. Start VisualGSM Service and test your new setup.

Start VisualGSM Service using the "Start" button on VisualGSM Enterprise Manager.

Send some SMSes to your VisualGSM Enterprise Server - you should receive a response SMS similar to the following example:

PhoneNumber:+6590601300
Keyword:Hello
Message:World
Modem Port:COM4
COMMMETHOD:
SMSC Number:
DB Seqno:1255491
Sendfrom:


Note:- If VisualGSM service does not start, refer to the returned message and check your setup. Refer to the next section, troubleshooting.

Proceed with live SMS testing (see Step 3). Refer to the sms server log file for testing details.

   
 
Troubleshooting
If you are facing any issues, please refer to the sms_server_log.txt file for logging details.

Default path for sms server log:
c:\Program Files\Visualtron Software Corporation\VisualGSM\vgsmlog\sms_server_log.txt


If you have any questions or comments, you may post on the support forum for this tutorial - click here.
 
 
Relevant links

Send SMS from Outlook (Via Exchange Server or Lotus Notes using POP3)
Send an SMS via email Demo
Build an SMS Directory Bot in just 4 hrs (including testing) How to configure Microsoft Exchange SMTP Connector to send SMS