Send SMS from Oracle ADF Application using Horizon SMS API

Sharing is Caring

This post is about using SMS API to send SMS from Oracle ADF application to mobile device
there are various SMS Gateway to send SMS using java and all java API’s can be used with Oracle ADF

here I am using SMS horizon (a bulk SMS provider in India) see this SMS API integration with Java and Oracle ADF, follow the steps
First, create an account with SMS Horizon – or User Login- SMS Horizon

you can purchase a trial package to test your code, they provide 200 SMS for Rs 25 only. So After purchasing the trial pack, you will get an API Key and username

Log in to your account and see your dashboard-

you will see your API key in this type of box-


Now the first step is complete and second and last step is to implement the code in your managed bean
you can find Sample API files (code to use API in Java, C#, PHP etc) from there

So for this, I have a created a Fusion Web Application and a page in it


Send SMS from Oracle ADF

created a managed bean and actionListener for this Send button
this url is used to send sms and it returns msgId of sent message******&apikey=*****8&mobile=xxyy&message=xxyy&senderid=xxyy&type=txt

See the ActionListener code –

    /**Method to send SMS using SMS Horizon API
     * @param actionEvent
public void sendSMSAction(ActionEvent actionEvent) {
    // get mobile number value using component binding
    if (mobNoBind.getValue() != null) {
        // Replace with your username
        String user = "userId";

        // Replace with your API KEY (We have sent API KEY on activation email, also available on panel)
String apikey = "your_api_key";

            // Replace with the destination mobile Number to which you want to send sms
String mobile = mobNoBind.getValue().toString();

            // Replace if you have your own Sender ID, else donot change
String senderid = "WEBSMS";

            // Replace with your Message content
String message = "SMS API -Oracle ADF";

            // For Plain Text, use "txt" ; for Unicode symbols or regional Languages like hindi/tamil/kannada use "uni"
String type = "txt";

            //Prepare Url
URLConnection myURLConnection = null;
URL myURL = null;
BufferedReader reader = null;

            //encoding message
String encoded_message = URLEncoder.encode(message);

            //Send SMS API
String mainUrl = "";

            //Prepare parameter string
StringBuilder sbPostData = new StringBuilder(mainUrl);
sbPostData.append("user=" + user);
sbPostData.append("&apikey=" + apikey);
sbPostData.append("&message=" + encoded_message);
sbPostData.append("&mobile=" + mobile);
sbPostData.append("&senderid=" + senderid);
sbPostData.append("&type=" + type);

            //final string
mainUrl = sbPostData.toString();
System.out.println("URL to Send SMS-" + mainUrl);
            try {
                //prepare connection
myURL = new URL(mainUrl);
myURLConnection = myURL.openConnection();
reader = new BufferedReader(new InputStreamReader(myURLConnection.getInputStream()));
                //reading response
String response;
                while ((response = reader.readLine()) != null) {
                    //print response
                //finally close connection

            } catch (IOException e) {

    public void setMobNoBind(RichInputText mobNoBind) {
        this.mobNoBind = mobNoBind;

    public RichInputText getMobNoBind() {
        return mobNoBind;

you can check the status of each SMS in your account that it is delivered or not, other than this you can also check the status of msg in your code also using this URL*****&apikey=*********&msgid=xxyy

pass msgId returned from the previous URL and it will return you the status of the message as- PENDING, DELIVERED etc
see imports used in code-



import javax.faces.event.ActionEvent;


Cheers 🙂 Happy Learning

Related Posts

5 thoughts on “Send SMS from Oracle ADF Application using Horizon SMS API”

Leave a Reply

Your email address will not be published. Required fields are marked *