Send Free SMS using JAVA & Grameenphone’s API (aloashbei.com)

31 Comments

Today I am going to show how to send SMS using Grameenphone’s API.

What I Used to built my application:

  1. JAVA
  2. NetBeans IDE 6.7

At first go to www.aloashbei.com and register there. This registration is required because it gives you a username & password in respect to your mobile no. This username & password is used in our application.

Let’s start. Open NetBeans IDE. Create an empty Java Application Project. Now we need to add a Web Service Client in our project.

Be sure our working project is set as Main Project. To do so right click on the Project Name in the Project Browser’s window and Select Set as Main Project.

Now go to File Menu >New File a window opens…..

For

Categories select > Web Services

File Types select > Web Service Client

Click Next > WSDL and Client Window Appears…..

Select WSDL URL and paste there:

https://www.aloashbei.com.bd/API/GP.ADP.BizTalk.SMS.Orchestrations/WebService_GP_ADP_BizTalk_SMS_Orchestrations.asmx?wsdl

Rest Will be same. Click Finish.

Now you need to import some packages from that web service to use in your application. Here is my completed code for NewClass.java :-

import com.grameenphone.playground.*;
import com.grameenphone.*;
import com.grameenphone.sendsmsrequest_xml.SendSMSRequest;

public class NewClass{

public static void main(String[] args) {
String regID = "yourUsername"; //put your aloashbei.com username here
String passWord = "yourPassword"; // put your aloashbei.com password here
String fromMSISDN = "8801746743391"; //put your GP mobile no. here
String toMSISDN = "8801746743391"; //put recipient’s GP mobile no. here
String smsPort = "5001"; //default port No.
double charge = 0.00; //this is why the SMS is free now

int msgType = 4; //4 is used for text sending; there are some others
String contentArea = "test";
String msgContent = "hi, this is my first software using gp API, i can send sms free..:)";

try {
WebServiceGPADPBizTalkSMSOrchestrations service = new WebServiceGPADPBizTalkSMSOrchestrations();
WebServiceGPADPBizTalkSMSOrchestrationsSoap port = service.getWebServiceGPADPBizTalkSMSOrchestrationsSoap();

SendSMSRequest messageRequest = new SendSMSRequest();

messageRequest.setRegistrationID(regID);
messageRequest.setPassword(passWord);
messageRequest.setSourceMsisdn(fromMSISDN);
messageRequest.setDestinationMsisdn(toMSISDN);
messageRequest.setSmsPort(smsPort);
messageRequest.setMsgType(msgType);
messageRequest.setCharge(charge);

messageRequest.setChargedParty(fromMSISDN);
messageRequest.setContentArea(contentArea);
messageRequest.setMsgContent(msgContent);

sendsmsresponse_xml.schemas.biztalk.adp.gp.SendSMSResponse result = port.sendSMS(messageRequest);

System.out.println("Result = " + result.getStatus() + " " + result.getMsgID()); //It shows message sending result…
} catch (Exception ex) {
ex.printStackTrace();
}
}
}

Now one important thing to do is changes in two files:

  1. Double Click on the marked two files:
  2. Replace http://192.168.100.169/API/GP.ADP.BizTalk.SMS.Orchestrations/WebService_GP_ADP_BizTalk_SMS_Orchestrations.asmx by https://www.aloashbei.com.bd/API/GP.ADP.BizTalk.SMS.Orchestrations/WebService_GP_ADP_BizTalk_SMS_Orchestrations.asmx in both of the files
  3. Now Clean & Build and Run NewClass.java to send SMS to a specific GP No. Be careful, in your every successful run it will send a SMS K. For test purpose you can use your mobile no. in both sender and receiver’s mobile # field.  There is a limitation in SMS sending/day. Probably it is 50 SMS/day. Hope it runs successfully. Cheers!

31 Responses to “Send Free SMS using JAVA & Grameenphone’s API (aloashbei.com)”

  1. munna

    thank you for your post. but brother i am facing the following problem, can you please have a look on that?

    C:workjavaEEGpSmsbuildgenerated-sourcesjax-wscomgrameenphoneplaygroundWebServiceGPADPBizTalkSMSOrchestrations.java:49: cannot find symbol
    symbol : constructor Service(java.net.URL,javax.xml.namespace.QName,javax.xml.ws.WebServiceFeature[])
    location: class javax.xml.ws.Service
    super(WEBSERVICEGPADPBIZTALKSMSORCHESTRATIONS_WSDL_LOCATION, WEBSERVICEGPADPBIZTALKSMSORCHESTRATIONS_QNAME, features);
    C:workjavaEEGpSmsbuildgenerated-sourcesjax-wscomgrameenphoneplaygroundWebServiceGPADPBizTalkSMSOrchestrations.java:57: cannot find symbol
    symbol : constructor Service(java.net.URL,javax.xml.namespace.QName,javax.xml.ws.WebServiceFeature[])
    location: class javax.xml.ws.Service
    super(wsdlLocation, WEBSERVICEGPADPBIZTALKSMSORCHESTRATIONS_QNAME, features);
    C:workjavaEEGpSmsbuildgenerated-sourcesjax-wscomgrameenphoneplaygroundWebServiceGPADPBizTalkSMSOrchestrations.java:65: cannot find symbol
    symbol : constructor Service(java.net.URL,javax.xml.namespace.QName,javax.xml.ws.WebServiceFeature[])
    location: class javax.xml.ws.Service
    super(wsdlLocation, serviceName, features);
    3 errors

    Reply
  2. zamanisgeek

    Hi Munna,
    I am not a expert on using xml or web services.But I guess your web service is not properly included in the project.

    Reply
  3. webtodev

    javax.xml.ws.WebServiceException: Cannot find ‘https://www.aloashbei.com.bd/API/GP.ADP.BizTalk.SMS.Orchestrations/WebService_GP_ADP_BizTalk_SMS_Orchestrations.asmx?wsdl’ wsdl. Place the resource correctly in the classpath.
    at com.grameenphone.playground.WebServiceGPADPBizTalkSMSOrchestrations.(WebServiceGPADPBizTalkSMSOrchestrations.java:34)
    at NewClass.main(NewClass.java:28)

    Why is this ? I followed the above instructions to the point and i am using Netbeans IDE 6.9

    Reply
    • zamanisgeek

      Then please check aloashbei.com.bd once again. Probably they have moved their services to another directory.

      Reply
      • webtodev

        Thanks for your quick reply . But the error said that “https://www.aloashbei.com.bd/API/GP.ADP.BizTalk.SMS.Orchestrations/WebService_GP_ADP_BizTalk_SMS_Orchestrations.asmx?wsdl”
        is not here …but i can still find something in this link .

        Reply
  4. mahbub

    ami netbeans 6.9 use kortesi. sekhane ektu onno rokom. ami j2me te kortesi. file>new file>j2me>j2me web service> ekhane ami wsdl er link disi. er por validate korte bolsi. sekhane validation er result ashse: reference in element is not supported by this version of stub compiler.

    can you please help on this regard?

    Reply
  5. Batook

    Hi bro,

    Thanks for posting this one. But i m facing same problem as above.
    error at newClass.java Line no 34.

    Thanks & Regards
    BatooK

    Reply
  6. mehul

    javax.xml.ws.WebServiceException: Cannot find ‘https://www.aloashbei.com.bd/API/GP.ADP.BizTalk.SMS.Orchestrations/WebService_GP_ADP_BizTalk_SMS_Orchestrations.asmx?wsdl’ wsdl. Place the resource correctly in the classpath.
    at com.grameenphone.playground.WebServiceGPADPBizTalkSMSOrchestrations.(WebServiceGPADPBizTalkSMSOrchestrations.java:34)
    at javaapplication2.newclass.main(newclass.java:34)

    this same error plz must be reply

    Reply
  7. pratik

    hi friends this great site.now i introduce a new site for sms fans http://www.freesmsapi.com .this is a grate for the people who generally connect with sms.i am sure once you visit you will visit regularly.just go there and check then tell me i am right or wrong.Thanks.I like to thanks owner of this site for sharing resources and information.Thanks

    Reply
  8. shoaib ahmed

    i did it.. i sent sms using gp api.. yahooooooo…

    Reply
  9. shoaib ahmed

    hello zamanisgeek,
    thank you for ur great help. i just made the job done.
    thank you onece again.

    Reply
  10. Abdullah Jayed

    Bro it’s only for Indians…..And we r Bangladeshi…..@Pratik bro

    Reply
  11. make your own dubstep

    Good news! this page has been accepted for http://www.interestingblogs.info . This blog is now featuring on our ‘featured blogs’ list.

    Reply
  12. S.J Evan

    hi.. i would positively try your code. but there are some comments above indicating problems to your code. are there really errors in it? anyway, i just want to inform you that i would take your post as a reference. thanks for your article.. 😀

    Reply
    • zamanisgeek

      Hi, Yes I tested it recently it is suffering the same problem they mentioned. I contacted the API team, but they couldn’t provide a good answer. And thanks for your comment. Cheers!

      Reply
  13. S.J Evan

    😀 no prob. I’m really thinking about doing the same concept as you have done.. I’m really looking forward to creating my own. Nice article though.. Keep it up

    Reply
  14. bdseoexpert

    I want to learn this on gerneral php not in soap can you help me

    Reply
  15. Rajkumar

    This is rajkumar,

    i run this program. but i got some error. pls, rectify this error. pls reply sir.

    javax.xml.ws.WebServiceException: Cannot find ‘https://www.aloashbei.com.bd/API/GP.ADP.BizTalk.SMS.Orchestrations/WebService_GP_ADP_BizTalk_SMS_Orchestrations.asmx?wsdl’ wsdl. Place the resource correctly in the classpath.
    at com.grameenphone.playground.WebServiceGPADPBizTalkSMSOrchestrations.(WebServiceGPADPBizTalkSMSOrchestrations.java:34)
    at freesms.NewClass.main(NewClass.java:27)

    Reply
  16. Rajkumar

    This is rajkumar,

    i run this program. i have some errors. pls rectify it. pls reply me.

    javax.xml.ws.WebServiceException: Cannot find ‘https://www.aloashbei.com.bd/API/GP.ADP.BizTalk.SMS.Orchestrations/WebService_GP_ADP_BizTalk_SMS_Orchestrations.asmx?wsdl’ wsdl. Place the resource correctly in the classpath.
    at com.grameenphone.playground.WebServiceGPADPBizTalkSMSOrchestrations.(WebServiceGPADPBizTalkSMSOrchestrations.java:34)
    at freesms.NewClass.main(NewClass.java:27)

    Reply
    • zamanisgeek

      Hi, I have contacted with the aloashbei team (www.aloashbei.com) in this regard. This is the reply from them:


      from Golam Md. Sarwar Grameenphone IT Ltd. golam_sarwar@gpit.com
      sender time Sent at 5:08 AM (GMT+06:00). Current time there: 04:39. ✆
      to “mashrufz@gmail.com”
      cc aloashbei
      date 31 March 2011 05:08
      subject RE: using SMS API in JAVA (Internal)
      Important mainly because of the words in the message.

      Please at first save the wsdl file locally and change the web service address. After that add the wsdl with your application from local location. Hope it will work fine.

      Thanks
      Md. Golam Sarwar

      Reply
  17. nikunj

    Hello sir i try your code but following error are coming pls help me

    init:
    Deleting: C:abhishekorajavaProjectbuildbuilt-jar.properties
    deps-jar:
    Updating property file: C:abhishekorajavaProjectbuildbuilt-jar.properties
    wsimport-init:
    wsimport-client-WebService_GP_ADP_BizTalk_SMS_Orchestrations:
    files are up to date
    wsimport-client-generate:
    Compiling 1 source file to C:abhishekorajavaProjectbuildclasses
    compile:
    run:
    java.lang.NoClassDefFoundError: project/NewClass
    Caused by: java.lang.ClassNotFoundException: project.NewClass
    at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
    Could not find the main class: project.NewClass. Program will exit.
    Exception in thread “main” Java Result: 1
    BUILD SUCCESSFUL (total time: 0 seconds)

    Reply
  18. Aviv

    i tried to test it by the instruction, but although i registered, application says “invalid user ID and password”. Y?

    Reply
  19. Charles

    If you want to send free international sms you can also try “http://www.smswind.de”. It is a German sms site for sending international free sms. There is a German and an English version. You can send there – 7 free sms ervery 24 hours – without registration – international – with 160 characters. Try!

    Reply
  20. Asraf

    Am having this error…
    javax.xml.ws.WebServiceException: Cannot find ‘https://www.aloashbei.com.bd/API/GP.ADP.BizTalk.SMS.Orchestrations/WebService_GP_ADP_BizTalk_SMS_Orchestrations.asmx?wsdl’ wsdl. Place the resource correctly in the classpath.
    at com.grameenphone.playground.WebServiceGPADPBizTalkSMSOrchestrations.(WebServiceGPADPBizTalkSMSOrchestrations.java:34)
    at sendsms.NewClass.main(NewClass.java:31)
    BUILD SUCCESSFUL (total time: 1 second)
    How to get rid of this

    Reply
  21. tarik hosain

    free ki kem ne pata bo

    Reply
  22. Yetta

    I tend not to write a leave a response, but I read through some remarks on Send Free SMS using
    JAVA & Grameenphone’s API (aloashbei.com)
    | Zaman Is Geek!. I actually do have a few questions for you if you tend not to mind.
    Is it only me or does it look as if like some of the remarks appear as if they
    are left by brain dead folks? 😛 And, if you are writing
    on additional social sites, I would like to keep up with everything fresh you have to
    post. Could you list of all of all your public sites like your twitter feed, Facebook page or linkedin profile?

    Reply
  23. online casino Bonus

    These are in fact impressive ideas in regarding
    blogging. You have touched some good factors here. Any way
    keep up wrinting.

    Reply

Leave a Reply