java - send sms from web application -
i trying send sms java application using smppsim sms gateway , smppapi
this code send sms
public class synctransmitter extends smppapiexample { private log logger = logfactory.getlog(synctransmitter.class); public synctransmitter() { } public void execute() { try { logger.info("binding smsc"); myconnection = new connection("localhost", 2775); myconnection.autoacklink(true); myconnection.autoackmessages(true); bindresp resp = myconnection.bind( connection.transmitter, "smppclient1", "password", null); /** bindresp resp = myconnection.bind( connection.transmitter, "smppclient1", "password", systemtype, sourceton, sourcenpi, sourceaddress); */ if (resp.getcommandstatus() != 0) { logger.info("smsc bind failed."); system.exit(1); } logger.info("bind successful...submitting message."); // submit simple message submitsm sm = (submitsm) myconnection.newinstance(smpppacket.submit_sm); sm.setdestination(new address(1, 8, "9988776655")); sm.setmessagetext("this example short message."); submitsmresp smr = (submitsmresp) myconnection.sendrequest(sm); logger.info("submitted message id: " + smr.getmessageid()); // unbind. unbindresp ubr = myconnection.unbind(); if (ubr.getcommandstatus() == 0) { logger.info("successfully unbound smsc"); } else { logger.info("there error unbinding."); } } catch (exception x) { logger.info("an exception occurred."); x.printstacktrace(system.err); } } } public static void main(string[] args) { system.out.println("test"); synctransmitter st = new synctransmitter(); st.execute(); system.out.println("done…."); }
this smppsim console output
2011.02.23 22:29:03 546 info 11 standardconnectionhandler accepted connection 2011.02.23 22:29:03 765 info 11 protocol handler of type standardprotocolhandler 2011.02.23 22:29:03 765 info 11 : bind_transmitter: 2011.02.23 22:29:03 765 info 11 hex dump (42) bytes: 2011.02.23 22:29:03 765 info 11 0000002a:00000002:00000000:00000001: 2011.02.23 22:29:03 765 info 11 736d7070:636c6965:6e743100:70617373: 2011.02.23 22:29:03 765 info 11 776f7264:00003400:0000 2011.02.23 22:29:03 781 info 11 cmd_len=42,cmd_id=2,cmd_status=0,seq_no=1,sys tem_id=smppclient1 2011.02.23 22:29:03 781 info 11 password=password,system_type=,interface_vers ion=52,addr_ton=0,addr_npi=0 2011.02.23 22:29:03 781 info 11 address_range= 2011.02.23 22:29:03 781 info 11 2011.02.23 22:29:03 781 info 11 new transmitter session bound smppsim 2011.02.23 22:29:03 781 info 11 : bind_transmitter_resp: 2011.02.23 22:29:03 781 info 11 hex dump (24) bytes: 2011.02.23 22:29:03 781 info 11 00000018:80000002:00000000:00000001: 2011.02.23 22:29:03 781 info 11 534d5050:53696d00: 2011.02.23 22:29:03 781 info 11 cmd_len=0,cmd_id=-2147483646,cmd_status=0,seq _no=1,system_id=smppsim 2011.02.23 22:29:03 781 info 11 2011.02.23 22:29:03 781 info 11 : standard submit_sm: 2011.02.23 22:29:03 781 info 11 hex dump (76) bytes: 2011.02.23 22:29:03 781 info 11 0000004c:00000004:00000000:00000002: 2011.02.23 22:29:03 781 info 11 00000000:01083939:38383737:36363535: 2011.02.23 22:29:03 781 info 11 00000000:00000000:00002154:68697320: 2011.02.23 22:29:03 781 info 11 69732061:6e206578:616d706c:65207368: 2011.02.23 22:29:03 781 info 11 6f727420:6d657373:6167652e: 2011.02.23 22:29:03 781 info 11 cmd_len=76,cmd_id=4,cmd_status=0,seq_no=2,ser vice_type=,source_addr_ton=0 2011.02.23 22:29:03 781 info 11 source_addr_npi=0,source_addr=,dest_addr_ton= 1,dest_addr_npi=8 2011.02.23 22:29:03 781 info 11 dest_addr=9988776655,esm_class=0,protocol_id= 0,priority_flag=0 2011.02.23 22:29:03 781 info 11 schedule_delivery_time=,validity_period=,regi stered_delivery_flag=0 2011.02.23 22:29:03 781 info 11 replace_if_present_flag=0,data_coding=0,sm_de fault_msg_id=0,sm_length=33 2011.02.23 22:29:03 781 info 11 short_message=this example short messag e. 2011.02.23 22:29:03 781 info 11 2011.02.23 22:29:03 796 info 11 validity period not set: defaulting 5 m inutes 2011.02.23 22:29:03 796 info 11 generated default validity period=11022322340 3000+ 2011.02.23 22:29:03 796 info 11 :submit_sm_resp: 2011.02.23 22:29:03 796 info 22 assessing state of 1 messages in outbound queue 2011.02.23 22:29:03 796 info 11 hex dump (18) bytes: 2011.02.23 22:29:03 796 info 11 00000012:80000004:00000000:00000002: 2011.02.23 22:29:03 796 info 11 3000 2011.02.23 22:29:03 796 info 11 cmd_len=0,cmd_id=-2147483644,cmd_status=0,seq _no=2,message_id=0 2011.02.23 22:29:03 812 info 11 2011.02.23 22:29:03 812 info 11 submitsm processing - response written con nection 2011.02.23 22:29:03 812 info 23 inboundqueue: no available receiver sessions - moving message(s) pending queue **exception in thread "thread-1" java.lang.classcastexception: [ljava.lang.object; cannot cast [lcom.seleniumsoftware.smppsim.pdu.pdu; @ com.seleniumsoftware.smppsim.inboundqueue.processqueue(unknown source ) @ com.seleniumsoftware.smppsim.inboundqueue.run(unknown source) @ java.lang.thread.run(unknown source) 2011.02.23 22:29:03 812 info 11 : unbind:** 2011.02.23 22:29:03 812 info 11 hex dump (16) bytes: 2011.02.23 22:29:03 812 info 11 00000010:00000006:00000000:00000003: 2011.02.23 22:29:03 812 info 11 2011.02.23 22:29:03 812 info 11 cmd_len=16,cmd_id=6,cmd_status=0,seq_no=3 2011.02.23 22:29:03 812 info 11 2011.02.23 22:29:03 812 info 11 : unbind_resp 2011.02.23 22:29:03 812 info 11 hex dump (16) bytes: 2011.02.23 22:29:03 812 info 11 00000010:80000006:00000000:00000003: 2011.02.23 22:29:03 812 info 11 2011.02.23 22:29:03 812 info 11 cmd_len=0,cmd_id=-2147483642,cmd_status=0,seq _no=3 2011.02.23 22:29:03 812 info 11 2011.02.23 22:29:03 812 info 11 standardconnectionhandler waiting connect ion 2011.02.23 22:29:08 796 info 22 assessing state of 1 messages in outbound queue 2011.02.23 22:29:13 796 info 22 assessing state of 1 messages in outbound queue 2011.02.23 22:29:18 796 info 22 assessing state of 1 messages in outbound queue 2011.02.23 22:29:23 796 info 22 assessing state of 1 messages in outbound queue 2011.02.23 22:29:28 796 info 22 assessing state of 1 messages in outbound queue 2011.02.23 22:29:33 796 info 22 assessing state of 1 messages in outbound queue 2011.02.23 22:29:38 796 info 22 assessing state of 1 messages in outbound queue 2011.02.23 22:29:43 796 info 22 assessing state of 1 messages in outbound queue 2011.02.23 22:29:48 796 info 22 assessing state of 1 messages in outbound queue 2011.02.23 22:29:53 796 info 22 assessing state of 1 messages in outbound queue 2011.02.23 22:29:58 796 info 22 assessing state of 1 messages in outbound queue 2011.02.23 22:30:00 250 info 24 processing 0 messages in delayed inbound queue 2011.02.23 22:30:03 796 info 22 assessing state of 1 messages in outbound queue 2011.02.23 22:30:08 796 info 22 assessing state of 1 messages in outbound queue 2011.02.23 22:30:13 796 info 22 lifecycle service: outboundqueue empty - waiting
i not able understand problem
also please suggest open source sms gateway
i'm not sure lib, can use smslib. requires mobile device gsm-capable act virtual sms aggregator.
Comments
Post a Comment