The first lines of this java servlet (including the 3 println statements) are examples of handling an HTTP request for an incoming SMS and the rest is for sending an HTTP request. You just need to configure Kannel to send an http request to the URL where the java servlet is running. In order to run Java servlets you need a Servlet Container such as Apache Tomcat (http://jakarta.apache.org/tomcat/index.html). So in your kannel.conf file you need to add a paragraph that looks something like this
group = sms-service keyword = default get-url = "http://my.apache.machine:8080/Servlet/MyServlet?sender=%p&text=%r&to=%P" max-messages = 0 Notice that the names I put as parameters in the http request are the same as I use in the code in order to retrieve them. (The 8080 port is the default port for the Tomcat Servlet Container) With this configuration incoming SMS messages are not stored anywhere they are just send to the Java Servlet as an http request. So it is up to the java servlet to store them somewhere if needed. In my code a second http request is made to another Kannel in order to forward the SMS to the CIMD2 SMSC, but the code can be changed to make a database insert for example. I am sorry but I am not familiar with PlaySMS so I can't help there. Spyros -----Original Message----- From: Ricky Wibowo [mailto:[EMAIL PROTECTED] Sent: Thursday, June 16, 2005 2:49 PM To: Sakellariou Spyros ([EMAIL PROTECTED]) Cc: [email protected] Subject: Re: Receiving SMPP connections. Thank you for answering my question Send SMS, I'm using HTTP GET/POST, and I've successed for sending, no problem at all But, If there is incoming SMS to my SMS Gateway, where is the message gone?? In which directory the message come?? (where's the spool directory??) I'm using SMPP protocol for this and using kannel + playsms for the web interface thank you Sakellariou Spyros ([EMAIL PROTECTED]) wrote: >I don't have a script for doing that. I am a Java Developer and I only know >how to do it as a Java Servlet so in Java it would be something like this: > >public class HttpSMSHandler extends HttpServlet { > public void init() throws ServletException { > } > > public void doGet(HttpServletRequest request, HttpServletResponse >response) throws ServletException, IOException { > > String sms-message-text = request.getParameter("text"); > String sms-message-originator = request.getParameter("sender"); > String sms-message-destination = request.getParameter("to"); > > System.out.println("The incoming message said: " + >sms-message-text); > System.out.println("The incoming message originator is: " + >sms-message-originator); > System.out.println("The incoming message destination is: " + >sms-message-destination); > > String >getRequest="http://www.theCIMDKannel.com:13013/cgi-bin/sendsms?username=foo & >password=bar > + "&from=" + sms-message-originator > + "&to=" + sms-message-destination > + "&text=" + sms-message-text; > > getRequest = getRequest.replace(' ', '+'); > > URL requestUrl = new URL( getRequest); > HttpURLConnection conn = ( HttpURLConnection >)requestUrl.openConnection(); > conn.disconnect(); > } >} > > > >I just wrote this as an example I don't even know if it compiles or works >but this is the general idea for a Java Servlet. Although it looks like it >should work 8-) > > >Spyros > >-----Original Message----- >From: Ricky Wibowo [mailto:[EMAIL PROTECTED] >Sent: Thursday, June 16, 2005 1:06 PM >To: [EMAIL PROTECTED] >Cc: [EMAIL PROTECTED] >Subject: Re: Receiving SMPP connections. > > >Have you the script for fetching the messages?? >Could you send me one?? > >Sakellariou Spyros ([EMAIL PROTECTED]) wrote: > > > >>I am pretty sure that Kannel can receive SMS's from SMPP connections. Well >> >> >I > > >>have only worked with limited CIMD2 and modem connections but I am sure >> >> >that > > >>it works with SMPP as well (anyone who knows differently please tell us). >> >>Kannel can be configured to forward an incoming SMS's as an HTTP POST or >> >> >GET > > >>request to a Web Server. All the SMS related information (including the >>message content) are included as HTTP REQUEST Parameters. Languages for >>writing web applications such as CGI, PERL, Java Servlets or PHP have >>request objects with all the parameters passed from Kannel to the web >>server. See the user guide on how to configure redirected replies - Kannel >>1.4.0 User's Guide page 113. >> >>In addition Kannel can send an SMS via CIMD2 (or SMPP or modem) by having >> >> >an > > >>external application making an HTTP POST or GET request to it - Kannel >> >> >1.4.0 > > >>User's Guide page 115. >> >>So what I am saying is to have a script on a web server like Apache that >>waits for an HTTP POST/GET request from a Kannel instance connected via >> >> >SMPP > > >>configured to accept incoming SMS's, then the script makes another HTTP >>POST/GET request to a Kannel instance connected to the commercial SMSC with >>CIMD2. >> >> >>So here is a flow if what I mean: >> >>incoming SMS >> | >> | >> v >>Kannel with SMPP makes HTTP Request to Apache Web Server >> | >> | >> v >>Script reads the Paramaters containing all the info about the incoming SMS >>Script makes an HTTP Request to Kannel for Sending an SMS >>passing as parameters the data read from the incoming SMS request >> | >> | >> v >>Kannel with CIMD2 >> | >> | >> v >>outgoing SMS >> >> >>I hope I didn't make it more confusing. >>I think this is a quick and dirty solution but it does require some >>programming. >> >>Spyros >> >> >> >>-----Original Message----- >>From: Matias K. [mailto:[EMAIL PROTECTED] >>Sent: Thursday, June 16, 2005 11:12 AM >>To: Sakellariou Spyros ([EMAIL PROTECTED]) >>Cc: [email protected] >>Subject: Re: Receiving SMPP connections. >> >> >>Thank you for your answer, I am a bit confused though. IF Kannel is >>not able to receive SMPP connections, how would this solution be of >>any benefit? I don't seem to get the big picture. I do understand that >>I have to have two smsc instances, one for the receiving SMPP (if that >>now is even possible) and one for the sending CIMD2. And I should >>somehow route (via http-request for example) the receiving SMPP to the >>sending CIMD2. Can somebody try to make me understand what I should >>do? Thank you in advance :) >> >>On 6/15/05, Sakellariou Spyros ([EMAIL PROTECTED]) >><[EMAIL PROTECTED]> wrote: >> >> >> >> >>>A quick and dirty solution is to have two kanel instances running: one for >>>SMPP and one for CIMD2, and write a small cgi script for Apache Web Server >>>that accepts HTTP requests for the incoming SMS from the SMPP instance and >>>makes an HTTP request for sending the SMS to the CIMD2 instance. >>> >>>Read the manual on how to configure kannel to make HTTP requests for >>>incoming SMS. >>>Depending on what you feel more comfortable with, instead of CGI you can >>>write a PERL script, PHP, Servlets or whatever can accept and submit HTTP >>>requests. >>> >>>Spyros >>> >>> >>> >>> >>> >>> >> >> >> >> >> >> > > > > >
