无法在java中通过SMPP发送多部分短信

发布于 2024-10-12 02:34:21 字数 1705 浏览 0 评论 0原文

我正在尝试用 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();
}

但这段代码似乎不起作用。我收到的是分成不同消息的消息,而不是在手机上串联的消息。

关于我在这里做错了什么的任何指示。

I am trying to send a multipart sms message in 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();
}

But this code doesn't seem to work. What I receive is messages split up in different messages and not concatenated on the handset.

Any pointers on what am I doing wrong here.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

旧故 2024-10-19 02:34:21

Raks,

请记住,并非世界上所有网络或世界上所有手机都已正确配置用于发送/接收多部分 SMS 消息。

由于您(正确地)伪装了实际的 SMSC 连接器,因此我不确定您连接到哪个运营商/聚合器。因此,我无法评论这是否是您具体情况下的问题。

但正如 Alexrs 所说,包括 TCP 转储输出,我们至少可以对来自您的应用程序的正确输出进行评论。

Raks,

Remember that not all networks in the world, nor all handsets in the world are configured correctly for sending/receiving the multi-part SMS messages.

As you have (rightly) disguised your actual SMSC connector, i'm not sure which carrier/aggregator you connect to. Therefore i can't comment if this is the problem in your specific situation.

But as Alexrs said, include the TCP Dump output and we can at least comment on the correct output coming from your app.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文