SMS Transport currently have two SMS implementations
SMPP protocol implementation
GSM implementation
where SMPP protocol implementation allow you to connect the axis2 to a SMSC and get messages form it. And GSM implementation allow you to connect a simple GSM modem to the computer that Axis2 is running and use that to send receive SMS form Axis2( its recommended not to use GSM implementation when your message traffic is higher than 6msgs per min).
SMS Transport allow Axis2 users to do following
Invoke a in only Web Service operation using a SMS
Invoke a in out Web service operation and receive a reply
Use Axis2 client and send messages out as a SMS
In this blog I 'll discuss how to use SMS Transport to invoke a simple a Web Service using a RPC type SMS via GSM implementation
Environment :
OS: Ubuntu 9.04
JDK : 1.6.0
Axis2 Version : 1.5.1
Modem : Huawei E220
Following are the Steps that need to be taken
Add Runtime Libs to Axis2 to Start with SMS Transport
Configure Axis2
Deploy our Simple service
Start Axis2
invoke service using a SMS.
Adding Runtime libs
add following file to the Axis2-HOME/lib directory
axis2-transport-sms-1.0.0.jar
axis2-transport-base-1.0.0.jar
smslib-3.4.1.jar
mail-1.4.jar
Now we need to add Java communication API libs needed for the SMS lib
go to jre home and goto lib/ext/ directory and add following files
comm.jar
libLinuxSerialParallel.so
libLinuxSerialParallel_g.so
Now we are Axis2 two is ready to start with Axis2 .
Configuring Axis2
Goto Axis2-HOME/conf folder where you find the axis2.xml file which is the configuration file used for Axis2 configuration.
Then add following to the Transport section.
SMS Transport Receiver configuration
<transportreceiver name="sms" class="org.apache.axis2.transport.sms.SMSMessageReciever">
<parameter name="smsImplClass">org.apache.axis2.transport.sms.gsm.GSMImplManager</parameter>
<parameter name="com_port">/dev/ttyUSB0</parameter>
<parameter name="gateway_id">modem.ttyUSB0</parameter>
<parameter name="baud_rate">115200</parameter>
<parameter name="manufacturer">HUAWEI</parameter>
<parameter name="model">E220</parameter>
</transportreceiver>
SMS Transport Sender configuration
<transportsender name="sms" class="org.apache.axis2.transport.sms.SMSSender">
<parameter name="smsImplClass">org.apache.axis2.transport.sms.gsm.GSMImplManager</parameter>
<parameter name="com_port">/dev/ttyUSB0</parameter>
<parameter name="gateway_id">modem.ttyUSB0</parameter>
<parameter name="baud_rate">115200</parameter>
<parameter name="manufacturer">HUAWEI</parameter>
<parameter name="model">E220</parameter>
</transportsender>
Now Axis2 is ready. Now lets write a Simple Axis2 Service
Deploy Axis2 Service
Following is the Sample POJO Axis2 Service Class I wrote to demonstrate this
package sample.sms.test;
public class SampleInOutService {
public String sayHello(String name) {
return "Hello " + name;
}
}
Make a service archive of this POJO class and put that in the Axis2-HOME/repository/services directory.
Start Axis2
Then Start Axis2 by going to Axis2-HOME/bin and executing the shell script axis2server.sh.
If every thing goes ok you will see a log like this at the end
[INFO] Version: 3.4.1
[INFO] JRE Version: 1.6.0_06
[INFO] JRE Impl Version: 10.0-b22
[INFO] O/S: Linux / i386 / 2.6.28-14-generic
[INFO] GTW: modem.ttyUSB0: Starting gateway, using Generic AT Handler.
[INFO] GTW: modem.ttyUSB0: Opening: /dev/ttyUSB0 @115200
[INFO] GTW: modem.ttyUSB0: GSM: Registered to home network.
[INFO] GTW: modem.ttyUSB0: MEM: Storage Locations Found: SM
[INFO] GTW: modem.ttyUSB0: Gateway started.
[Axis2] Started in Port :/dev/ttyUSB0
[INFO] [SimpleAxisServer] Started
Now we are done now we can invoke the sayHello operation by sending a SMS message to the modem
following is the SMS
SampleInOutService:sayHello:name=charith
send that SMS to the modems phone number and you will get a SMS saying Hello charith
You can use SMS Transport Mixing implementations. ex : send messages using SMPP and recive via GSM modem.
This Transport will be useful when your going to implement your EDA (Event driven architecture) since users will be able to generate events and/or get notifications of events via SMSs
More details of SMS Transport can be found at SMS Transport documentation