I have made a REST Web Service to send SMSs using a HSDPA USB modem. I am using SMSLib in Java to send SMSs. Every time the web service is invoked, I create the gateway start the service, send message, stop service and remove gateway. This takes about 20 seconds for each message. I found that starting the service takes a lot of time. This is the part of code I use to send SMSs
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
Is there a way I can start the service once if it is not started and use it to send a message when ever the web service is invoked?