SMS With WSO2 ESB
Let's take a look at how to send an SMS for the request number in the JSON request with a message in JSON.
Join the DZone community and get the full member experience.
Join For Free1) Introduction to SMPP and SMSC
SMPP — Short Message Peer to Peer protocol is an open, industry standard protocol designed to provide a flexible data communications interface for transfer of short message data between a Message Center, such as a Short Message Service Centre (SMSC), GSM Unstructured Supplementary Services Data (USSD) Server, or other types of message center and SMS application systems, such as a WAP Proxy Server, Email Gateway, or other messaging gateway. The advantage of supporting SMPP protocol with the Axis2 SMS Transport is that it can be used to send and receive a high volume of short messages very fast. SMPP protocol is an application layer protocol that can be used over TCP. There are many SMPP gateways available in the world, and now almost all the message centers support SMPP.
Use Case 01
There is HTTP SMS API and the user can invoke it with HTTP call with JSON. The API is able to send an SMS for the request number in the JSON request with a message in JSON.
2) Prerequisite
- JSMPP lib
JSMPP is a Java implementation of SMPP protocol. It provides an API to communicate with an SMSC and JSMPP can be download from here (http://central.maven.org/maven2/com/googlecode/jsmpp/jsmpp/)
- An SMSC Simulator
SMSC Simulator is an application that can act like an SMSC. Using a simulator, we can test our scenario without having access to a real SMSC. For the real production servers, we have to use a real SMSC. In here we will be using OpenSmpp (https://github.com/OpenSmpp/opensmpp)
- SMPP connector for ESB
It can be download from here. (https://store.wso2.com/store/assets/esbconnector/details/1f5ca0e2-3fe0-42e5-ae9b-05af1f8e361b)
3) Setting the SMSC Simulator
3.1) Get Git clone on OpenSmpp and build it.
3.2) Create the "users.txt" file in "etc"
3.3) Add following contain for the file
name=wso2esb
password=passesb
timeout=unlimited
3.4) Start the simulator with below command
java -cp opensmpp-core-3.0.3-SNAPSHOT.jar;opensmpp-sim-3.0.3-SNAPSHOT.jar;opensmpp-charset-3.0.3-SNAPSHOT.jar org.smpp.smscsim.Simulator
3.5) Enter "1" to "start simulation" and give the port number as "2775."
Then it will start a listener and it is notified with log message as below
4) Setting Up the ESB
4.1) Add the "jsmpp_2.1.0.jar" to lib directory in ESB or EI
4.2) Add the SMPP Connector to the WSO2 ESB from the web console or developer studio
5) Creating API
5.1) Create API in wso2 ESB with “POST” method.
5.2) You can get full WSO2 ESB API from here.
5.3) Here is JSON request to pass for that newly created API.
6) Testing API With OpenSmpp
6.1) Send the JSON request from Postman (You will get 202 status to respond)
6.2) You will able to see some logs in your simulator as below, such as "Connection accepted."
6.3) In the simulator when you press "5," you should see the SMS you send from the API on ESB.
References
[1] https://docs.wso2.com/display/ESBCONNECTORS/Sending+SMS+Message#SendingSMSMessage-Overview
Published at DZone with permission of Madhuka Udantha, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.
Comments