我正嘗試在java中發送多部分短消息。不能通過SMPP發送多部分短信在java中
public static void main(String[] args) throws Exception {
SMPPSession session = new SMPPSession();
session.connectAndBind("0.0.0.0", 00000, new BindParameter(
BindType.BIND_TX, "User", "Pass", "SMPP", TypeOfNumber.UNKNOWN,
NumberingPlanIndicator.UNKNOWN, null));
Random random = new Random();
final int totalSegments = 3;
OptionalParameter sarMsgRefNum = OptionalParameters.newSarMsgRefNum((short) random.nextInt());
OptionalParameter sarTotalSegments = OptionalParameters.newSarTotalSegments(totalSegments);
for (int i = 0; i < totalSegments; i++) {
final int seqNum = i + 1;
String message = "Message part " + seqNum + " of " + totalSegments + " ";
OptionalParameter sarSegmentSeqnum = OptionalParameters
.newSarSegmentSeqnum(seqNum);
String messageId = session.submitShortMessage("CMT", TypeOfNumber.INTERNATIONAL,
NumberingPlanIndicator.UNKNOWN, "919999999999", TypeOfNumber.INTERNATIONAL,
NumberingPlanIndicator.UNKNOWN, "919999999999", new ESMClass(),
(byte) 0, (byte) 1, timeFormatter.format(new Date()), null,
new RegisteredDelivery(SMSCDeliveryReceipt.DEFAULT), (byte) 0,
new GeneralDataCoding(false, false, MessageClass.CLASS1,
Alphabet.ALPHA_8_BIT), (byte) 0, message.getBytes(),sarSegmentSeqnum, sarTotalSegments, sarMsgRefNum);
System.out.println("Message submitted, message_id is " + messageId);
}
session.unbindAndClose();
}
但是,這段代碼似乎不起作用。我收到的消息是分成不同的消息,而不是連接在手機上。
任何指針我在做什麼錯在這裏。
我建議你用[Wireshark](http://www.wireshark.org/)獲得發送的網絡跟蹤。它有一個很棒的SMPP協議處理程序,它將顯示數據包的所有標誌和選項。如果您在發佈詳細信息時仍遇到問題,我可能會提供幫助。 – alexrs 2011-05-31 19:10:45