Friday, April 10, 2015

Liferay SMS Portlet

Generally in our real time developments we may need to send SMS from our applications same way we can get requirement to send SMS from Portlet in Liferay development.

When we send SMS we need following things
  • We need to purchase BULK SMS from SMS vendors
  • We need BULK SMS Vendor SMS API to use in our application.

BULK SMS vendor

There are many bulk SMS vendors in the market we can register with them and we can purchase BULK SMS.

Each vendor is responsible to provide username and password so that we will use these credentials to send SMS in our Portlet development

The following are Bulk SMS Vendors


Bulk SMS vendors are responsible to provide SMS sender API so that we will use SMS sender API to send SMS from our application.

SMS sender API Types

  • WEB Service API (SOAP/REST)
  • Language Specific API


SMS vendors will provide SOAP/REST API to send SMS from our applications and it will provide set of classes or some request URL so that we can use those to send SMS.

Language Specific API

Based on language they will provide Language specific implementation  so that we can use those packages in our application.

Here we are going to use JAVA specific implementation because Liferay portal developed by java.
Generally they will provide some jar file and it consist some set of interfaces and classes so that we can use their API classes to send SMS from our Portlet.


This is one of most used API to send SMS in applications. SMS vendors will provide request URL and its consist request parameters and its values as query string .Once we prepared request URL we can  ping that URL then SMS will be send it to destination.

We just prepare URL and hit in browser address bar then we can send SMS. In application we will use Apache Http Client or package to ping URL in java code.

Example URL to Send SMS

URL Consist following things

Vendor Host Name: Main Host name of Vendor ( )

Common Request Parameters

Source:  It’s like Alpha numeric String visible to receiver when they received SMS

Destination mobile Number: Actual receiver mobile number

Message: Text Message

User Name: SMS Vendor register user name

Password: SMS vendor register user password


Request parameter names will be changed based on the SMS vendor

SMS Portlet Implementation

To test SMS Portlet we need one SMS vendor and “vianett” is vendor they provide 5 sample SMS for testing purpose

We should register with vianett so that we can get 5 free SMS so we can use this account in code implementation to send SMS

Once we register we get password to our mail and we can change later. Vianett register username and password will be used to send SMS

In the example we use Apache HTTP API/Java NET Package to send SMS we have different request URL parameter we need pass appropriate values to each parameter so that we can send SMS. We can have URLs like send SMS URL and to know delivery status we have other Delivery Status Request URL such a way they provided different URL for different purpose.

Please have look into API document to know more information.

Download Portlet Source Code.


Once you downloaded Portlet you need to modify code in the Portlet action class with respect to SMS vendor HTTP URL and Its request parameters then you can test.

Portlet  Screen

VaiNett Login Page

VaiNett Customer Landing Page

Complete Code Implementation

Portlet View JSP page (/html/jsps/view.jsp)

<%@page import="com.liferay.portal.kernel.servlet.SessionErrors"%>
<%@page import="com.liferay.portal.kernel.servlet.SessionMessages"%>
<%@ taglib uri="" prefix="liferay-portlet"%>
<%@ taglib uri="" prefix="liferay-theme"%>
<%@ taglib uri="" prefix="liferay-ui"%>
<%@ taglib uri="" prefix="portlet"%>
<%@ taglib uri="" prefix="aui"%>
.aui .control-group {
margin-bottom: 0px;
<portlet:defineObjects />
<liferay-theme:defineObjects />
<portlet:actionURL var="sendSMSActionURL" windowState="normal"
<% if(SessionMessages.contains(renderRequest.getPortletSession(),"SMS-send-success")){%>
<liferay-ui:success key="SMS-send-success" message="SMS has been sent successfully." />
<%} %>
<% if(SessionErrors.contains(renderRequest.getPortletSession(),"SMS-send-error")){%>
<liferay-ui:error key="SMS-send-error" message="There is problem in Request URL te send SMS." />
<%} %>
<aui:form action="<%=sendSMSActionURL%>" method="post" name="smsForm">
<aui:input name="mobileNumber" id="mobileNumber" label="Mobile Number">
<aui:validator name="required" />
<aui:validator name="digits"></aui:validator>
<aui:validator name="minLength">10</aui:validator>
<aui:validator name="maxLength">10</aui:validator>
<aui:input name="textMessage" id="textMessage" label="SMS Text Message" type="textarea">
<aui:validator name="required" />
<span style=" float: left;">Characters Left&nbsp;</span><p id="<portlet:namespace/>textCounter"></p>
<aui:button type="submit" value="Send SMS"></aui:button>

AUI().use('aui-char-counter', function(A) {
new A.CharCounter({
counter : '#<portlet:namespace/>textCounter',
input : '#<portlet:namespace/>textMessage',
maxLength : 140,
on : {
maxLength : function(event) {
alert('The max length limit was reached');

Portlet Action Class (

package com.meera.liferay.sms;


import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
import javax.portlet.PortletException;

import com.liferay.counter.service.CounterLocalServiceUtil;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.kernel.servlet.SessionErrors;
import com.liferay.portal.kernel.servlet.SessionMessages;
import com.liferay.portal.kernel.util.ParamUtil;
import com.liferay.util.bridges.mvc.MVCPortlet;

* Portlet implementation class LiferaySMS
public class LiferaySMS extends MVCPortlet {
public static final String VENDOR_HOST_URL= "";
public static final String VENDOR_USERNAME_RQUEST_PARAM_VALUE= "";
public static final String 
VENDOR_PASSWORD_RQUEST_PARAM_VALUE= "your sms vendor password";
public static final String COUNTRY_CODE= "91";
public void sendSMS(ActionRequest actionRequest,
ActionResponse actionResponse) throws IOException, PortletException, SystemException {
String textMessage = ParamUtil.getString(actionRequest,"textMessage");
String mobileNumber = ParamUtil.getString(actionRequest,"mobileNumber");
long messageId = CounterLocalServiceUtil.increment();
HttpURLConnection connection = null;
URL completeSenderURL = null;
String conncetionResponse = null;
StringBuilder smsSenderURLQueryString = new StringBuilder();
try {
//Prepare URL query String with required Parameters.
smsSenderURLQueryString.append("username=" + URLEncoder.encode(VENDOR_USERNAME_RQUEST_PARAM_VALUE, "UTF-8"));
smsSenderURLQueryString.append("&password=" + URLEncoder.encode(VENDOR_PASSWORD_RQUEST_PARAM_VALUE, "UTF-8"));
smsSenderURLQueryString.append("&msgid=" + URLEncoder.encode(String.valueOf(messageId), "UTF-8"));
smsSenderURLQueryString.append("&tel=" + URLEncoder.encode(COUNTRY_CODE+mobileNumber, "UTF-8"));
smsSenderURLQueryString.append("&msg=" + URLEncoder.encode(textMessage, "UTF-8"));

//Complete SMS Sender Request URL
String completeSenderURLString=
VENDOR_HOST_URL+"?"+smsSenderURLQueryString.toString();"SMS Sender URL"+completeSenderURLString);

//Create JAVA NET URL from URL String
completeSenderURL = new URL(completeSenderURLString);
connection = (HttpURLConnection) completeSenderURL.openConnection();
conncetionResponse = connection.getResponseMessage();
int responseCode = connection.getResponseCode();
if (responseCode == HttpURLConnection.HTTP_OK) {
SessionMessages.add(actionRequest.getPortletSession(),"SMS-send-success");"SMS has been sent successfully"+responseCode);
SessionErrors.add(actionRequest.getPortletSession(),"SMS-send-error");"There is problem in Request URL to send SMS"+responseCode);
}"URL Respond Data"+conncetionResponse);
}catch (UnsupportedEncodingException e) {
catch(MalformedURLException mue){
}catch (Exception e) {

private static Log _log = LogFactoryUtil.getLog(LiferaySMS.class);


  1. Hi there, I read your blogs on a regular basis. Your humoristic style is witty, keep it up! Thank You for Providing Such a Unique and valuable information, If you are looking for the best Unlimited Bulk SMS,then visit NORSMS. I enjoyed this blog post.

  2. What a fantabulous post this has been. Never seen this kind of useful post. I am grateful to you and expect more number of posts like these. Thank you very much. text messaging platforms

  3. Wow, What a Excellent post. I really found this to much informatics. It is what i was searching for.I would like to suggest you that please keep sharing such type of info.Thanks business texting services

  4. Yahoo mail is an web based email service. Yahoo mail service can be accessed through different devices including computer, tablets, smart phones, and more. Users with a valid Yahoo account can sign into Yahoo com to access the features of Yahoo mail. A smile web browser can be used to sign into Users can also download Yahoo app to their mobile phone and login to their account. yahoo mail sign in

  5. buy smart carts online. organic smart cart. are the high potency distillate free from any solvents. If this product was accurate with its claim.

  6. Stonersdankshop established in 2016 in United States has been the best vape shop exporting vape products online to most vape shops in USA and to vape . big chief extracts

  7. Royal photo Booths Australia At Royal Booths,we want to make a good impression with you, hence we go above & beyond when it comes to forming that initial relationship with our customers.

  8. Journey to San Diego: ups and downs

    The day when I planned to move to San Diego, due to my endeavors and job issues. It was the day, where I knew how things would go after we would travel. I’ve been reading about the city before I finally decided to move to San Diego. The first thing that fascinated me about San Diego was the different climate seasons San Diego has.

  9. Fashion line of beauty

    The Bridal Planner is the leading destination fashion planner based in Goa, India. Founded in 2013, by Sadneep, a former Goa engineer, after her own destination fashion in Goa. With experience as an expatriate of over 10 years in various countries prior to forming The Bridal Planner, Sadneep has gained an appreciation for client expectations of luxury, professionalism and efficiency on an international scale. Her clients have been from all over the world including celebrities and a high profile company which were featured in various media in South East Asia and Europe.

  10. seo fastest

    SEO has never been easier with this new and exclusive SEOFASTEST SEO Planner Tool.
    Just drag and drop your favorite packages into the calendar and hit the order button!
    No multiple order processes anymore! Buy backlinks with a click of a button!

  11. pure white Visit our stylish gentlemen's boutique in the centre of Antwerp called Les garçons Antwerp. In addition to our large range of shoes online, we also offer men's

  12. raw feeding, dog Are you a cat or dog owner looking to maximize nourishment for your furry family members? As a pet parent, you naturally strive to provide your pets with the best lifestyle options available

  13. reviewsyard

    At Reviews Yard Blog, we are committed to creating unique and customized content for our users that is useful for detailed information. We focus on applied information and a range of topics that can impact users in different technology areas.

  14. Build your English foundational skills - including reading, writing and critical analysis - in our private English tutoring program

  15. gogoanime

    GogoAnime - Watch anime online in high quality for free. Watch anime subbed, anime dubbed online free. Update daily, fast streaming, no ads, no registration ...

  16. Autoankauf Auf der Suche nach einem seriösen Autoankäufer in NRW sind Sie bei uns genau richtig. Wir garantieren Ihnen eine sichere und seriöse Abwicklung rund um den Autoankauf in NRW.

  17. bokep jav Bokep Indo, Bokep Barat, Bokep Asia, Bokep Gay, Bokep Semi.

  18. Thank you for oder my Gigs. Please share the details guide in the project

    shaw internet plans

  19. kissanime app The best place to watch dub and sub anime online and absolitely for free - KissAnime. With over 10000 different animes - KissAnime is the best source for anime ...

  20. Neuseeland Visum Thisare a private website offering our users online application services which include assistance with their application for Electronic Travel Authorization for travel to India. 

  21. voyance telephone espoir. wow, great, I was wondering how to cure acne naturally. and found your site by google, learned a lot, now i’m a bit clear. I’ve bookmark your site and also add rss. keep us updated.

  22. anti tarnish

    Archivists and conservators both worry about metal corrosion. Anti-Tarnish Strips prevent silver, gold, copper, brass, nickel, bronze and pewter items from tarnishing during shipment, storage, and display. These anti-tarnish strips won't off-gass or leave a residue

  23. Motivational Podcast

    Welcome to The CLS Experience! I’m your host Craig Siegel. I've dedicated myself to personal growth and transformation by revamping my mindset and now I want to help others manufacture BIG breakthroughs of their own.

  24. backing tracks Paris Music Here at Paris Music Limited we specialise in producing high quality, sound-a-like professional backing tracks for singers and performers.

  25. Geo-Environmental Consultants Adeptus is a specialist environmental consultancy advising on important technical and regulatory issues related to pollution, environmental risk, sustainability and efficiency.

  26. new zealand eta New Zealand has in place quite stringent biosecurity laws at its borders to prevent the accidental or intentional entry of harmful pests, germs, foreign pathogens or diseases. All such high risk material, food or non-food related must be declared or be binned/disposed of in marked garbage

  27. TAXPRO is a chief expert administration firm enhancing the matter of its customers for over 30 decades. We do this by giving a wide array of administrations in the monetary space which ranges from Entry Level Strategy, Taxation consultancy administrations, GST, Audit and Assurance, Accounting, Corporate Compliance, Payroll Services, ESI/PF Consultancy, and part more. We are a group of expense experts that incorporates Chartered Accountants, Advocates, Company Secretaries, Financial counselors offering marketing for accounting firm to the makers, Traders, Dealers, and specialist organizations of the business. Our administrations are looked for different business, lawful, and tax assessment confusions.

  28. Wonderful blog! I found it while surfing around on Yahoo News. Do you have any suggestions on how to get listed in Yahoo News? I’ve been trying for a while but I never seem to get there! Appreciate it. SMS Marketing - massen sms versenden

  29. movierulz 2021 APK Download for Android Mobile, Free Download MovieRulz App Telugu, Tamil, English, Kannada for your Android TV, Android.

  30. i never know the use of adobe shadow until i saw this post. thank you for this! this is very helpful. flexispy review

  31. slotxo thai

    เกมส์สล็อตออนไลน์เหล่านี้เป็นเกมส์ที่ยอดนิยม และมีผู้เล่นมากที่สุดตั้งแต่ แอพ Slotxo ได้เปิดให้บริการมานั่นเอง จากตัวอย่างจะแสดงให้เห็นได้ว่าเกมส์สล็อตออนไลน์ จาก SLOTXO นั้นมีธีมของเกมส์ที่แตกต่างหลากหลายกันออกไป ไม่ว่าจะเป็นแนว

  32. slot joker

    For a new website, there are many promotions to choose from. HUBJOKER888 is a website that has been launched with an automatic system, whether it is making transactions, applying for membership, depositing, withdrawing, making transactions.

  33. สำหรับท่านที่ต้องการเล่น pgslot ไม่ว่าจะเล่นผ่าน บราวเซอร์ Chrome , Firefox , Safari อื่นๆ เป็นต้น สามารถ ติดตั้งโปรแกรมบรคอมพิวเตอร์บนระบบปฏิบัติการ IOS หรือ Windows และสามารถเล่นได้สะดวกทุกที่บนมือถือที่เป็นสมาร์ทโฟน บน Iphone , Ipad และ Android .

    pg slot auto
    ทางเข้า pg slot
    pg slot โปรโมชั่น
    pg slot ทดลองเล่นฟรี
    pg slot ฝากถอนไม่มีขั้นต่ํา
    pg slot game
    pg slot demo
    pgslot เครดิตฟรี
    ดาวโหลด pgslot
    pgslot auto
    pgslot 77
    queenslot pgslot
    pgslot download
    slotkub pgslot
    pgslot 100
    slotxd pgslot
    superslot pgslot
    pgslot 311
    สล็อต pgslot
    pgslot สมัคร
    โปร pgslot

  34. We offer all the major sports such as English Premier League, Spanish La Liga, Italian Serie A, UEFA Champions League, French Ligue 1, German Bundesliga 1.


  35. หนังโป๊ฝรั่ง หนังโป๊ไทย xvideos หนังโป๊เกย์ ดูหนัง 18+ หนังอีโรติก คลิปโป๊นักศึกษา หนัง​โป๊ญี่ปุ่น เย็ดหี แตกใน xnxx Japanese Erotica.

    free porn

  36. Citycarpart

    We are a team of enthusiastic developers and entrepreneurs who decided to convert their common experience into this web store. We hope you’ll like it as much as we do and have a great shopping experience here. Our prime goal is to create a shop in which you can easily find whatever product you need.

  37. ULTRACLUB ASIA บาคาร่าออนไลน์ มาตรฐานระดับสากล
    สมัคร ฝาก-ถอน อัตโนมัติทั้งระบบ พร้อมทีมแอดมินมืออาชีพ

    Sexy baccarat
    ไพ่แคง ออนไลน์

  38. เว็บไซต์ที่ให้บริการเกมส์เดิมพันคาสิโนออนไลน์ทุกรูปแบบ อาทิเช่น เดิมพัน บาคาร่าออนไลน์ ผ่านมือถือได้เงินจริง ไพ่เสือมังกร ไฮโล รูเล็ต แบล็คแจ็ค เดิมพันเกมส์ไพ่ต่างๆ ป๊อกเด้ง ไพ่แคง น้ำเต้าปูปลา ไพ่สามกอง เป่ายิงฉุบได้เงินจริง ปั่นแปะผ่านมือถือ สามารถเล่นร่วมกับสมาชิกท่านอื่นที่เดิมพันอยู่จริง

    เสือมังกร ออนไลน์
    เสือมังกร วิธีเล่น
    ไฮโล วิธีเล่น
    รูเล็ต วิธีเล่น

  39. You have done a great job on this article. It’s very readable and highly intelligent. You have even managed to make it understandable and easy to read. You have some real writing talent. Thank you
    non voip sms verifications

  40. Yes i am totally agreed with this article and i just want say that this article is very nice and very informative article.I will make sure to be reading your blog more. You made a good point but I can't help but wonder, what about the other side? !!!!!!THANKS!!!!!! mobile toilet for rent

  41. i love reading this article so beautiful!!great job! bathroom rental

  42. Pretty good post. I just stumbled upon your blog and wanted to say that I have really enjoyed reading your blog posts. Any way I'll be subscribing to your feed and I hope you post again soon. Big thanks for the useful info. high dofollow backlinks

  43. Missed Call Number Services Noida – Techbuzz offers the fastest way to know your customer with missed call alert services . Easy customization available here.

  44. I just wanted to say that I love every time visiting your wonderful post! Very powerful and have true and fresh information. Thanks for the post and effort! Please keep sharing more such a blog.

    For Visit:

    Visit Website: Whatsapp Marketing

  45. Great post. I was checking continuously this blog and I am impressed! Very useful info specifically the last part :) I care for such info much. I was looking for this certain information for a very long time. Thank you and best of luck. Get It SMS is a India No 1 Bulk SMS in Bangalore. We are giving special offer in bulk SMS service. Our Services are Voice SMS, promotional bulk SMS, transactional SMS, miss call service, bulk e-mailing, transactional bulk SMS, Missed call alert Whatsapp SMS and website Design. Sign Up for a free trial!

  46. Do you want to start a business or looking for a startup? Are you looking for a WhatsApp reseller panel to start your business? You have come to the right place to have the service of the WhatsApp reseller panel. GetItSMS is providing the services of a WhatsApp Reseller Panel to help entrepreneurs. With this service, they can start a new business as the world is choosing the best bulk SMS service for their businesses. WhatsApp bulk SMS service has become one of the top services after marketing a business in the market. If you are looking for a WhatsApp reseller service provider in India or in any part of the country. We will provide you with the best service to start your business in India.

    Jaipur the city of heritages! The city is also called Pink City, being one of the most popular tourist’s attractions all over the world has created opportunities for all types of businesses in Jaipur. Whether they are travel agencies, hotels or services of tourist guides, Bulk SMS in Jaipur can help them to approach all those customers that need them. Cities like Jaipur are hubs for all types of businesses small or large so all companies want to promote their services. Promoting your service through multimedia may be expensive for your business even though all these need an audience to see your still or motion advertising. If your targeted audience doesn’t come to all these platforms your time and money will be wasted and this is a big worry for you!

  47. Writing a blog post is really important for the growth of your websitesBulk WhatsApp Messaging For Business . Thanks for sharing amazing tips. Following these steps will transform the standard of your blog post for sure.

  48. MEGA GAME นำไปเล่นเกมได้ทุกๆ เกมในเวลานี้ทางค่ายของเรานั้นจะมาจัดโปรโมชั่นแสนพิเศษให้กับผู้ที่เข้ามาเล่นทุกท่าน เครดิตฟรี 100 เพียงเท่านี้


Recent Posts

Recent Posts Widget

Popular Posts