java - 使用 SMSLib 和 Web 服务发送 SMS

标签 java web-services rest sms-gateway smslib

我创建了一个 REST Web 服务来使用 HSDPA USB 调制解调器发送短信。我正在 Java 中使用 SMSLib 发送短信。每次调用 Web 服务时,我都会创建网关,启动服务、发送消息、停止服务并删除网关。每条消息大约需要 20 秒。我发现启动服务需要花费很多时间。 这是我用来发送短信的代码部分

        Service.getInstance().addGateway(gateway);
        Service.getInstance().startService();

        OutboundMessage msg = new OutboundMessage(phoneNumber, message);

        if (Service.getInstance().sendMessage(msg)) {          
            result = "Message sent successfully!!";
        } else {
            result = "Could not send message.";
        }
        Service.getInstance().stopService();
        Service.getInstance().removeGateway(gateway);//remove the gateway

有没有一种方法可以在服务未启动的情况下启动一次,并在调用 Web 服务时使用它发送消息?

最佳答案

为什么不将消息分组并一次性发送?

Service.getInstance().sendMessages(messageList, gateway.getGatewayId()); 

关于java - 使用 SMSLib 和 Web 服务发送 SMS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39096574/

相关文章:

Java "The blank final field may not have been initialized"匿名接口(interface)与 Lambda 表达式

java - 使用 LuaJ 推送 int

java - 如何使用SFTP协议(protocol)多次尝试上传?

c# - Web 服务和 Entity Framework ?

c# - 无法添加服务引用

java - 如何通过 Spring Rest Api 检查文件是否已完全下载

python - 使用 App Engine 和 Webapp 休息 Web 服务

java - 注释掉@Test导致测试失败

c# - 数据库/网站状态的 Web 服务

c# - 在 C# 中使用 wcf 将 web url 作为参数传递到 web 服务中