gpt4 book ai didi

java - 通过 SMPP 发送多条短信

转载 作者:行者123 更新时间:2023-12-01 04:37:18 25 4
gpt4 key购买 nike

我会直接回答我的问题。

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

    }

异常(exception)是:

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

有人知道吗?

最佳答案

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

关于java - 通过 SMPP 发送多条短信,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17167783/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com