Re: [Asterisk-java-users] Asterisk java with tomcat
Brought to you by:
srt
From: preetha A. <pre...@gm...> - 2008-04-21 05:10:52
|
Thank you for your reply.I want to pass the callerid from the fastagi program to a jsp page .for this what should i do?mines is normal fastagi program like the HelloAgiScript program given in http://asterisk-java.org/development/tutorial.html .I didnt use any spring framework,application context,or anything.whether i have to use all these to pass a callerid?if yes, please explain me how to use spring framework. On 4/20/08, S. Brett Sutton <bs...@no...> wrote: > > to run fastagi you will need to startup up a thread during application > context initialization to act as the fast agi server. > > To do this implement a *ServletContextListener<http://java.sun.com/products/servlet/2.3/javadoc/javax/servlet/ServletContextListener.html>and during the 'contextInitialized' method call create a the thread which > will run your fastagi server. > > Note: the ServletContextListener needs to be configured in your web.xml. > * > > preetha Ayyappan wrote: > > Hi, > As you have done the managerAPI in java servlet,Is it possible to do the > following fastagi in servlet?if yes please guide me to do this. > > Code: > import java.io.IOException; > iimport org.asteriskjava.fastagi.AgiChannel; > import org.asteriskjava.fastagi.AgiException; > import org.asteriskjava.fastagi.AgiRequest; > import org.asteriskjava.fastagi.BaseAgiScript; > import org.asteriskjava.fastagi.DefaultAgiServer; > import org.asteriskjava.fastagi.AgiScript; > > public class Callerid extends BaseAgiScript implements AgiScript > > { > public void service(AgiRequest request, AgiChannel channel) > throws AgiException > { > > String callerid=request.getCallerId(); > System.out.println(callerid); > } > } > > On 3/27/08, Maciek Tokarski <mlo...@gm...> wrote: > > > > Hi, > > Let's say that you want to originate some call to somebody by clicking > > button on HTML site. PHP script will look something like that > > > > > > ----PHP CODE filename: clickToCall.php > > > > > > <?php > > if (!isset($_POST['call']) or $_POST['call']=='') { > > //display form to user > > ?> > > <form action="clickToCall.php" method="POST"> > > <input type="text" name="destination" value="enter destination number > > here...."> > > <input type="submit" value="call" name="call"> > > </form> > > <?php > > } else { > > //call web service using curl > > $destination=$_POST['destination']; > > > > $ch = curl_init(); > > $url="http://your.tomcat.host/serletname?dest=$destination"; //you can > > also use fopen or file_get_contents functions > > curl_setopt($ch, CURLOPT_URL,$url); > > curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); > > curl_setopt($ch, CURLOPT_POST, 1); > > curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_data); > > > > $data = curl_exec($ch); > > if ($data='OK') { > > echo "Ok... call is no the way"; > > } else { > > echo "Some problems...:-("; > > } > > } > > ?> > > ---end of PHP code > > I thin it won't work if You use Ctrl-C Ctrl-V, but it may looks like > > thise above > > > > Next you have to write a web service servlet that will handle request > > from php script: > > > > > > ----JAVA CODE > > > > package clickToCall; > > > > import java.io.*; > > import javax.servlet.*; > > import javax.servlet.http.*; > > import org.asteriskjava.manager.AuthenticationFailedException; > > import org.asteriskjava.manager.ManagerConnection; > > > > > > > > import org.asteriskjava.manager.ManagerConnectionFactory; > > import org.asteriskjava.manager.TimeoutException; > > import org.asteriskjava.manager.action.OriginateAction; > > import org.asteriskjava.manager.response.ManagerResponse; > > > > > > > > > > public class HelloWorld extends HttpServlet { > > public void doGet(HttpServletRequest request, > > HttpServletResponse response) > > throws ServletException, IOException { > > > > > > PrintWriter out = response.getWriter(); > > > > > > String destinationNo=request.getParameter("dest"); > > //pasted from http://asterisk-java.org/development/tutorial.html :-) > > > > > > try { > > > > ManagerConnectionFactory factory = new ManagerConnectionFactory( > > "localhost", "manager", "pa55w0rd"); // > > > > > > this.managerConnection = factory.createManagerConnection(); > > > > > > OriginateAction originateAction; > > ManagerResponse originateResponse; > > > > originateAction = new OriginateAction(); > > > > originateAction.setChannel("SIP/YOUR_TRUNK_NAME/"+destination); > > > > originateAction.setContext("default"); > > originateAction.setExten("1300"); > > > > originateAction.setPriority(new Integer(1)); > > originateAction.setTimeout(new Integer(30000)); > > > > > > // connect to Asterisk and log in > > managerConnection.login(); > > > > // send the originate action and wait for a maximum of 30 seconds for Asterisk > > > > // to send a reply > > originateResponse = managerConnection.sendAction(originateAction, 30000); > > > > > > > > > > // and finally log off and disconnect > > managerConnection.logoff(); > > > > > > out.println("OK"); > > } catch (Exception e) { > > out.println("NOT OK"); > > > > > > } > > > > } > > } > > > > ---End of JAVA code > > > > > > It also won't work after pasting it. Remember to put your Trunk name > > context etc. when setting up originate action. Of course you have to set up > > your Tomcat with this servlet. Php script can be simply putted into > > /varr/www folder of your server > > > > > > > > > > 2008/3/27, Gopal krishnan <sa...@gm...>: > > > > > > Hi, > > > > > > Thanks for the reply, can I have any help or hello world example to > > > set this. It would be a great help for me. Thanks > > > > > > On Thu, Mar 27, 2008 at 2:51 PM, Maciek Tokarski <mlo...@gm...> > > > wrote: > > > > > > > HI, > > > > Yes- it is possible. Once, I've developed Tomcat servlet (simple > > > > WebService) on Asterisk box to monitor users count on MeetMe rooms. It works > > > > fine. In my opinion best way of integrating manager API with HTML sites is > > > > interract with Asterisk not exacly via Tomcat servlet but via WebServices > > > > servlets (on Tomcat) calling it form eg. PHP scripts using CURL. > > > > > > > > Your SITE<------CURL/SOAP------>Tomcat WS servlet<--AMI--->Asterisk > > > > Box > > > > > > > > > > > > Regards, Maciek > > > > > > > > 2008/3/27, Gopal krishnan <sa...@gm...>: > > > > > > > > > > Hi, > > > > > > > > > > Is it possible I can use a manager api program with tomcat. If > > > > > so how should i integrate that, please assist me. > > > > > > > > > > I would like to initate a action from a html page so that it > > > > > will hit a program developed with manager api. > > > > > > > > > > -- > > > > > Thank you with regards, > > > > > Gopal, > > > > > PeopleTech Systems Private Limited > > > > > www.peopletech.co.in > > > > > > > > > > ------------------------------------------------------------------------- > > > > > Check out the new SourceForge.net Marketplace. > > > > > It's the best place to buy or sell services for > > > > > just about anything Open Source. > > > > > > > > > > http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace > > > > > _______________________________________________ > > > > > Asterisk-java-users mailing list > > > > > Ast...@li... > > > > > https://lists.sourceforge.net/lists/listinfo/asterisk-java-users > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > ------------------------------------------------------------------------- > > > > Check out the new SourceForge.net Marketplace. > > > > It's the best place to buy or sell services for > > > > just about anything Open Source. > > > > > > > > http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace > > > > _______________________________________________ > > > > Asterisk-java-users mailing list > > > > Ast...@li... > > > > https://lists.sourceforge.net/lists/listinfo/asterisk-java-users > > > > > > > > > > > > > > > > > -- > > > Thank you with regards, > > > Gopal, > > > PeopleTech Systems Private Limited > > > www.peopletech.co.in > > > > > > > > > ------------------------------------------------------------------------- > > > Check out the new SourceForge.net Marketplace. > > > It's the best place to buy or sell services for > > > just about anything Open Source. > > > > > > http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace > > > _______________________________________________ > > > Asterisk-java-users mailing list > > > Ast...@li... > > > https://lists.sourceforge.net/lists/listinfo/asterisk-java-users > > > > > > > > > > > > -- > > Pozdrawiam > > Maciek Tokarski > > > > ------------------------------------------------------------------------- > > Check out the new SourceForge.net Marketplace. > > It's the best place to buy or sell services for > > just about anything Open Source. > > > > http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace > > _______________________________________________ > > Asterisk-java-users mailing list > > Ast...@li... > > https://lists.sourceforge.net/lists/listinfo/asterisk-java-users > > > > > > > -- > Preetha.A > > ------------------------------ > > ------------------------------------------------------------------------- > This SF.net email is sponsored by the 2008 JavaOne(SM) Conference > Don't miss this year's exciting event. There's still time to save $100. > Use priority code J8TL2D2. > http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone > > ------------------------------ > > _______________________________________________ > Asterisk-java-users mailing list > Ast...@li... > https://lists.sourceforge.net/lists/listinfo/asterisk-java-users > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by the 2008 JavaOne(SM) Conference > Don't miss this year's exciting event. There's still time to save $100. > Use priority code J8TL2D2. > > http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone > _______________________________________________ > Asterisk-java-users mailing list > Ast...@li... > https://lists.sourceforge.net/lists/listinfo/asterisk-java-users > > -- Preetha.A |