我正在尝试使用 SMSLib 和 USB GSM 调制解调器发送短信。我在 Maven 项目中执行此操作,并且在 pom.xml 中有以下依赖项:
<dependency>
<groupId>org.smslib</groupId>
<artifactId>smslib</artifactId>
<version>dev-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.rxtx</groupId>
<artifactId>rxtx</artifactId>
<version>2.1.7</version>
</dependency>
<dependency>
<groupId>commons-net</groupId>
<artifactId>commons-net</artifactId>
<version>3.1</version>
</dependency>
<dependency>
<groupId>com.googlecode.jsmpp</groupId>
<artifactId>jsmpp</artifactId>
<version>2.1.0</version>
</dependency>
我的java代码如下:
Service.getInstance().start();
Modem gateway = new Modem("ZTE", "COM5", "19200", "0000", "0000", "9800005000");
MsIsdn msIsdn = new MsIsdn("9841252521");
gateway.setSmscNumber(msIsdn);
try {
Service.getInstance().registerGateway(gateway);
OutboundMessage outboundMsg = new OutboundMessage(msIsdn.getAddress(), "Hello there!");
Service.getInstance().send(outboundMsg);
} finally {
gateway.stop();
Service.getInstance().stop();
}
SMSlib 的文档指出我需要定义一个网关,例如
XYZ g = new XYZ("my-username", "my-password");
据我了解,我相信这应该是已连接的调制解调器。我对此很陌生,所以我无法真正理解“调制解调器”构造函数的参数应该是什么样的
Modem gateway = new Modem(gatewayId, address, port, simPin, simPin2, smscNumber,memoryLocations)
或者
Modem gateway = new Modem(gatewayId, parms)
我如何知道参数 gatewayId、address、simPin、simPin2 和 memroyLocations?
目前,运行代码时出现以下错误:
exception
java.lang.reflect.InvocationTargetException
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
......
root cause
java.lang.NoClassDefFoundError: Could not initialize class org.smslib.Service
com.mail.utility.SendSmsUtility.sendSMS(SendSmsUtility.java:11)
com.mail.action.SendSmsAction.sendSms(SendSmsAction.java:11)
......