使用SMSLib和Web服务发送SMS
问题描述:
我已经使用HSDPA USB调制解调器发送了SMS的REST Web服务。我使用Java中的SMSLib发送短信。每次调用Web服务时,都会创建网关启动服务,发送消息,停止服务并删除网关。每条消息大约需要20秒。我发现启动服务需要很长时间。 这是我用来发送短信使用SMSLib和Web服务发送SMS
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());
那不行。我需要在调用Web服务后立即发送它。谢谢。 –