每当我尝试在方法onAcceptDeliverSm(DeliverSm deliverSm)
之外提交短消息时,我都会遇到异常。这是我正在运行的代码:
public void onAcceptDeliverSm(DeliverSm deliverSm)
throws ProcessRequestException {
try {
String messageId = session.submitShortMessage("USSD", TypeOfNumber.NETWORK_SPECIFIC, NumberingPlanIndicator.PRIVATE, "420", TypeOfNumber.INTERNATIONAL, NumberingPlanIndicator.ISDN, msisdn, new ESMClass(),
(byte) 0, (byte) 1, timeFormatter.format(new Date()), null, new RegisteredDelivery(SMSCDeliveryReceipt.DEFAULT), (byte) 0, new GeneralDataCoding((byte) 15), (byte) 0, "Welcome.".getBytes(), new OptionalParameter.Byte(OptionalParameter.Tag.USSD_SERVICE_OP, (byte) 2));
} catch (PDUException ex) {
Logger.getLogger(MessageReceiverListenerImpl.class.getName()).log(Level.SEVERE, null, ex);
} catch (ResponseTimeoutException ex) {
Logger.getLogger(MessageReceiverListenerImpl.class.getName()).log(Level.SEVERE, null, ex);
} catch (InvalidResponseException ex) {
Logger.getLogger(MessageReceiverListenerImpl.class.getName()).log(Level.SEVERE, null, ex);
} catch (NegativeResponseException ex) {
Logger.getLogger(MessageReceiverListenerImpl.class.getName()).log(Level.SEVERE, null, ex);
} catch(IOException e) {
}
}
上面的代码工作正常。但是当我尝试将参数传递给另一个类时,submitsm无效。 :(
public void onAcceptDeliverSm(DeliverSm deliverSm)
throws ProcessRequestException {
Processor processor = new Processor(session, msisdn);
}
处理器类:
Class Processor {
public Processor(SMPPSession session, String msisdn) {
this.msisdn = msisdn;
this.sessionid = sessionid;
this.input = input;
this.circle_id = circle_id;
this.session = session;
String messageId = session.submitShortMessage("USSD", TypeOfNumber.NETWORK_SPECIFIC, NumberingPlanIndicator.PRIVATE, "420", TypeOfNumber.INTERNATIONAL, NumberingPlanIndicator.ISDN, msisdn, new ESMClass(),
(byte) 0, (byte) 1, timeFormatter.format(new Date()), null, new RegisteredDelivery(SMSCDeliveryReceipt.DEFAULT), (byte) 0, new GeneralDataCoding((byte) 15), (byte) 0, input.getBytes(), new OptionalParameter.Byte(OptionalParameter.Tag.USSD_SERVICE_OP, (byte) 2));
}
}
请告诉我问题出在哪里? 全部谢谢