Caused by: java.lang.RuntimeException: CommPortIdentifier class not found?at org.smslib.helper.CommPortIdentifier.<clinit>(CommPortIdentifier.java:76)?... 4 more但是這個類org.smslib.helper.CommPortIdentifier我是能找到的?private?static?String?COM;?//短信端口
????private?static?Service?srv;
????private?static?OutboundMessage?msg;
????static?OutboundNotification?outboundNotification;?//?=?new?OutboundNotification();
????static?SerialModemGateway?gateway;
????public?static?int?Send(String?PhoneNumber,?String?Content)?{
????????int?successnumber?=?0;
????????try?{
?????????????
????????????msg?=?new?OutboundMessage(PhoneNumber,?Content);
??????????//??msg.setEncoding(MessageEncodings.ENCUCS2);?//?中文
????????????srv.sendMessage(msg);
????????????//判斷發送狀態
????????????if?(msg.getMessageStatus().toString().trim().equals("SENT")?||?msg.getMessageStatus().toString().trim().equals("send"))?{
???????????????++?successnumber;
????????????}?else?{
????????????????System.out.println("SendMessage-->第"?+?(successnumber?+?1)?+?"條短信發送短信失??!");
????????????}
????????????System.out.println("SendMessage-->發送短信結束,成功條數:"?+?successnumber?+?"條,短信內容:"?+?Content);
????????????//返回成功數量
????????????return?successnumber;
????????}?catch?(Exception?e)?{
????????????e.printStackTrace();
????????????System.out.println("SendMessage-->發送異常??!");
????????????return?0;
????????}
????}
????public?static?void?Close()?{
????????try?{
????????????srv.stopService();
????????????srv.removeGateway(gateway);
????????????System.out.println("SendMessage-->關閉短信接口成功!");
????????}?catch?(GatewayException?e)?{
????????????e.printStackTrace();
????????????System.out.println("SendMessage-->關閉端口出錯!");
????????}?catch?(SMSLibException?e)?{
????????????e.printStackTrace();
????????????System.out.println("SendMessage-->關閉SMSLib錯誤!");
????????}?catch?(IOException?e)?{
????????????e.printStackTrace();
????????}?catch?(InterruptedException?e)?{
????????????e.printStackTrace();
????????}
????}
????public?class?OutboundNotification?implements?IOutboundMessageNotification?{
????????public?void?process(AGateway?agateway,?OutboundMessage?outboundmessage)?{
????????????System.out.println("SendMessage-->Outbound?handler?called?from?Gateway:?"?+?agateway);
????????????System.out.println("SendMessage-->"?+?outboundmessage);
????????}
????}
????static?{
????????COM?=?"COM3";
????????srv?=?Service.getInstance();
????????gateway?=?new?SerialModemGateway("modem."?+?COM.toLowerCase(),?COM,?9600,?"wavecom",?"");?//?設置端口與波特率
????????gateway.setInbound(true);
????????gateway.setOutbound(true);
????????gateway.setSimPin("1234");
????????//gateway.setOutboundNotification(outboundNotification);
????????srv.setOutboundMessageNotification(outboundNotification);?//發送短信成功后的回調函方法
????????try?{
????????????srv.addGateway(gateway);
?????????
????????????srv.startService();
????????????System.out.println("SendMessage-->服務啟動成功");
????????}?catch?(TimeoutException?e)?{
????????????e.printStackTrace();
????????}?catch?(GatewayException?e)?{
????????????e.printStackTrace();
????????}?catch?(SMSLibException?e)?{
????????????e.printStackTrace();
????????}?catch?(IOException?e)?{
????????????e.printStackTrace();
????????}?catch?(InterruptedException?e)?{
????????????e.printStackTrace();
????????}
????}附上相關代碼,不知道哪里設置錯了
添加回答
舉報
0/150
提交
取消