1

我想通过 jsmpp 发送 USSD 消息。当我发送消息时,我收到此错误

org.jsmpp.extra.NegativeResponseException: Negative response 00000008 found
        at org.jsmpp.session.AbstractSession.validateResponse(AbstractSession.java:215)
        at org.jsmpp.session.AbstractSession.executeSendCommand(AbstractSession.java:271)
        at org.jsmpp.session.SMPPSession.submitShortMessage(SMPPSession.java:320)

这是我的代码:

            int i = 2;
            short j = 2;
            OptionalParameter op1 = new OptionalParameter.Byte(Tag.USSD_SERVICE_OP, (byte) i);
            OptionalParameter op2 = new OptionalParameter.Byte(Tag.ITS_SESSION_INFO, (byte) j);
            OptionalParameter[] op = new OptionalParameter[2];

            op[0] = op2;
            op[1] = op1;

            messageId = session.submitShortMessage("USSD", TypeOfNumber.UNKNOWN,
                    NumberingPlanIndicator.UNKNOWN, sourceNumber, TypeOfNumber.UNKNOWN,
                    NumberingPlanIndicator.UNKNOWN, recipient, new ESMClass(142),
                    (byte) 0, (byte) 1, timeFormatter.format(new Date()), null,
                    new RegisteredDelivery(SMSCDeliveryReceipt.SUCCESS_FAILURE), (byte) 0,
                    DataCoding.newInstance(0),
                    (byte) 0, text.getBytes(), op);
4

1 回答 1

3

The parameter ITS_SESSION_INFO in general is used to maintain a session, use

OptionalParameter op2 = null;
for (OptionalParameter optionalParameter : deliverSm.getOptionalParametes()) {
    if (optionalParameter.tag == Tag.ITS_SESSION_INFO.code()) {
       op2 = optionalParameter;
    }
}
int i = 2;
OptionalParameter op[] = new OptionalParameter[2];
OptionalParameter op1 = new OptionalParameter.Byte(Tag.USSD_SERVICE_OP, (byte) i);
op[0] = op1;
if (op2 != null) {
    op[1] = op2;
}
于 2012-10-09T18:53:31.430 回答