1

我会直接回答我的问题。

  1. 我正在使用 Logica smpp,我想向多个号码发送短信。下面的代码给出异常。

    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 {
    }
    

    }

例外是:

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

有人知道吗?

4

1 回答 1

0

假设您的代码充当 ESME,则必须在发送任何 SubmitSM、SubmitMultiSM 或 DataSM 之前发送绑定请求(通过 BindTransmitter 或 BindTransciever)。

于 2013-06-18T12:07:50.907 回答