简体   繁体   English

通过SMPP发送多个短信

[英]Sending Multiple Sms through SMPP

I will come straight on my question. 我将直接回答我的问题。

  1. I am using Logica smpp and I want to send sms to multiple numbers. 我正在使用Logica smpp,我想发送短信到多个号码。 below code giving exception. 下面的代码给出了异常。

     public void submitMulti() { String serviceType = ""; byte replaceIfPresentFlag = 0; String scheduleDeliveryTime = null; String validityPeriod = null; byte esmClass = 0; //###################### //byte protocolId = 0; //byte dataCoding = 0; byte protocolId = 0; //0x00; commented is for flash byte dataCoding = (byte) 0x08; //0x18 byte smsClass = 0x00; //###################### byte ton = 1; byte npi = 1; byte priorityFlag = 0; byte registeredDelivery = 0; //TODO registered delivery byte smDefaultMsgId = (byte) 12; //0; try { SubmitMultiSM request = new SubmitMultiSM(); SubmitMultiSMResp response; // input values and set some :-) String sourceAddress = "123456789012"; int numberOfDestination = 10; for (int i = 0; i < numberOfDestination; i++) { request.addDestAddress(new DestinationAddress(new Address(ton,npi,"923458503302"))); } // set other values request.setServiceType(serviceType); request.setSourceAddr(sourceAddress); request.setReplaceIfPresentFlag(replaceIfPresentFlag); request.setShortMessage("Hy"); request.setScheduleDeliveryTime(scheduleDeliveryTime); request.setValidityPeriod(validityPeriod); request.setEsmClass(esmClass); request.setProtocolId(protocolId); request.setPriorityFlag(priorityFlag); request.setRegisteredDelivery(registeredDelivery); request.setDataCoding(dataCoding); request.setSmDefaultMsgId(smDefaultMsgId); String ipAddress = Bundle.getInstance().getValue(Bundle.Application_Contants.IP_ADDRESS.toString()); int port = Integer.valueOf(Bundle.getInstance().getValue(Bundle.Application_Contants.PORT.toString())); long receiveTimeOut = Long.valueOf(Bundle.getInstance().getValue(Bundle.Application_Contants.RECEIVE_TIMEOUT.toString())); TCPIPConnection connection = new TCPIPConnection(ipAddress,port); connection.setReceiveTimeout(receiveTimeOut); customSession = new Session(connection); // send the request System.out.println("Submit Multi request " + request.debugString()); if (!asynchronous) { customSession.submitMulti(request); } else { response = customSession.submitMulti(request); System.out.println("Submit Multi response " + response.debugString()); messageId = response.getMessageId(); } } catch (Exception e) { log.error(e,e); System.out.println("Submit Multi operation failed. " + e.getMessage()); } finally { } 

    } }

And the Exception is: 例外是:

java.lang.NullPointerException
at org.smpp.Session.send(Session.java:1100)
at org.smpp.Session.send(Session.java:1173)
at org.smpp.Session.submitMulti(Session.java:727)
at com.noetic.topUpBooster.smpp.JarConnection.submitMulti(JarConnection.java:413)
at com.noetic.sdp.alerts.JarCheck.run(JarCheck.java:34)
Submit Multi operation failed. null

does anyone have idea? 有人有主意吗?

假设您的代码充当ESME,则必须先发送绑定请求(通过BindTransmitter或BindTransciever),然后才能发送任何SubmitSM,SubmitMultiSM或DataSM。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM