
While sending the SMS message, send it to the same mobile number that you are using as a GSM modem to send the message. Then use the same device as the GSM modem. Though I have suggested the use of two Nokia 6600 mobile sets (one to be used as GSM modem, another to be used as the Java ME client), you can test the behavior with only one.

Write a message-driven bean to pick up the message, and then it will make a Web service call to the service (which embeds the SMS sending code). For example, when you try to send a message to a device, put it inside a Java Message Service queue with the required information (mobile number, port, message, etc.). But, since we're using a GSM modem, the SMS sending speed is slow so if we call the interface (RMI or Web service) directly, it is better to use an asynchronous design. An alternate solution embeds such code in a separate standalone, vanilla RMI (remote method invocation) server or Web service server, and accesses it from the application server. Point to note: Since SMSLib uses the Java Communications API, or RxTx, which makes native calls to the operating system, I suggest not embedding such code directly in the application server or Web server. In Step 11, make sure while running the SendMessageWithPortsSMSLib, you have the recently built JAR (the changes for RxTx) in your classpath and that it is using RXTXcomm.jar and the rxtxSerial.dll file instead of the Java Communications API's comm.jar and corresponding dll file.

To eliminate those errors, I commented out some lines in CSerialDriver. Now, in my case, I received some errors while sending the SMS message because I have a virtual port mapping for infrared connections.

But in a real-world scenario, you will not use a mobile phone as a modem, but a real GSM modem, which connects through a real COM (serial) port. As I write this article, RxTx supports physical serial connections well, but shows some exceptions for "virtual" serial ports, i.e., emulated serial ports via Bluetooth/infrared/USB connections. For SMSLib to work with RxTx, edit CSerialDriver.java and remove line m.*.
