我想通过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);
答案 0 :(得分:3)
参数ITS_SESSION_INFO通常用于维护会话,使用
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;
}