Thread: [Asterisk-java-users] Asterisk java with tomcat
Brought to you by:
srt
From: Gopal k. <sa...@gm...> - 2008-03-27 08:04:37
|
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 |
From: Maciek T. <mlo...@gm...> - 2008-03-27 09:21:47
|
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 > > |
From: Gopal k. <sa...@gm...> - 2008-03-27 10:38:12
|
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 |
From: Maciek T. <mlo...@gm...> - 2008-03-27 13:59:46
|
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 |
From: preetha A. <pre...@gm...> - 2008-04-19 09:25:34
|
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 |
From: S. B. S. <bs...@no...> - 2008-04-20 09:58:52
|
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... > <mailto: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... > <mailto: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... <mailto: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... > <mailto: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 <http://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... > <mailto: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... > <mailto:Ast...@li...> > https://lists.sourceforge.net/lists/listinfo/asterisk-java-users > > > > > -- > Thank you with regards, > Gopal, > PeopleTech Systems Private Limited > www.peopletech.co.in <http://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... > <mailto: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... > <mailto: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 > |
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 |
From: <bs...@no...> - 2008-04-21 06:20:36
|
What you are looking to do doesn't quite make sense so you might have to review your approach. The issue is that under normal circumstances a JSP page is called into action by a user entering a url into their web browser. You are looking to call the JSP page into action when a new phone call enters your asterisk server which doesn't fit the normal JSP model. There are ways around this problem but we probably need to know a bit more regarding what you are trying to do. Taking a guess at what you are trying to do, I would suggest: One possible solution is the AJAX model of programming which is some times used to 'simulate' server event handling. Basically your html would contain AJAX code which does a request to the server. Unlike a normal http request the server would not respond immediately. Instead it would put the servlet to sleep with a 'wait()' statement. When a fastagi event arrives the servlet would be woken up using a 'notify()' statement. The servlet can then obtain the caller id from the fastagi service and return the details to the html page. The HTML page can then take further action using javascript to display a page based on the caller id. The servlet also needs to return periodically otherwise the browser gets upset. This is non-trival coding. We have an AJAX based 'Answer bar' which we have developed which uses a similar technique to 'screen pop' a web page and I know the developers spent a fair bit of time to get it working just right. We also used the manager api rather than the fastagi, but either will probably work, the manager api simply delivers more information and doesn't require hooks in the dial plan. Regards, Brett preetha Ayyappan <pre...@gm...> wrote: > 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 > |
From: preetha A. <pre...@gm...> - 2008-04-21 12:58:49
|
Hi, * The servlet can then obtain the caller id from the fastagi service and return the details to the html page.* I understand what you are saying.but how to use this? On Mon, Apr 21, 2008 at 11:46 AM, <bs...@no...> wrote: > > What you are looking to do doesn't quite make sense so you might have to > review your approach. > > The issue is that under normal circumstances a JSP page is called into > action by a user entering a url into their web browser. > You are looking to call the JSP page into action when a new phone call > enters your asterisk server which doesn't fit the normal JSP model. > > There are ways around this problem but we probably need to know a bit more > regarding what you are trying to do. > > Taking a guess at what you are trying to do, I would suggest: > > One possible solution is the AJAX model of programming which is some times > used to 'simulate' server event handling. > Basically your html would contain AJAX code which does a request to the > server. > Unlike a normal http request the server would not respond immediately. > Instead it would put the servlet to sleep with a 'wait()' statement. When > a fastagi event arrives the servlet would be woken up using a 'notify()' > statement. > The servlet can then obtain the caller id from the fastagi service and > return the details to the html page. The HTML page can then take further > action using javascript to display a page based on the caller id. > > The servlet also needs to return periodically otherwise the browser gets > upset. > > This is non-trival coding. We have an AJAX based 'Answer bar' which we > have developed which uses a similar technique to 'screen pop' a web page and > I know the developers spent a fair bit of time to get it working just right. > We also used the manager api rather than the fastagi, but either will > probably work, the manager api simply delivers more information and doesn't > require hooks in the dial plan. > > Regards, > Brett > > > > preetha Ayyappan <pre...@gm...> wrote: > > 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 > > > > > > > -- Preetha.A |
From: Stefan R. <ste...@re...> - 2008-04-21 13:48:02
Attachments:
signature.asc
|
Hi, I would like to thank Brett for his kind support and the sound answers he provided, but I am not sure that effort is successful in this particular case. This list should be a helpful resource to everybody seeking help on using Asterisk-Java and surrounding technologies. We are happy to help you get started and provide answers to challenging questions but we asume that you have a basic knowledge of your stuff. This is definitly not the place to cry for copy-and-paste solutions. If you are not able to do your job better leave it to someone else. preetha Ayyappan wrote: > I understand what you are saying.but how to use this? Based on your repeated questions I don't think you understood a single word. Your seem to be hanging around here to grab pre-baked solutions that you can relabel as your work results and that's just not what we are here for. Please accept this and look elsewhere for idiots who are willing to do your work for free. To all others: Sorry for being a bit harsh but we had a similar discussion on the -dev mailing list recently and I really get sick of those help vampires. I don't want to discurage anybody from asking stupid questions, most of them are great learning opportunities for everybody. It's just that I won't accept to turn this list into a Java newbie list or a how-do-webapps-work list. There are certainly better places to acquire this knowledge though it will certainly require more work than copy-and-paste from an email and hitting the compile button. =Stefan -- reuter network consulting Neusser Str. 110 50760 Koeln Germany Telefon: +49 221 1305699-0 Telefax: +49 221 1305699-90 E-Mail: ste...@re... Jabber: ste...@re... WWW: http://www.reucon.com Steuernummern 215/5140/1791 USt-IdNr. DE220701760 |
From: Maciek T. <mlo...@gm...> - 2008-03-27 14:00:27
|
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 Regards, Maciek 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 |
From: Gopal k. <gop...@pe...> - 2008-03-28 04:51:05
|
Hi, Thank you , let me try this with some tweaking. On Thu, Mar 27, 2008 at 7:29 PM, 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 > > -- Thank you with regards, Gopal, PeopleTech Systems Private Limited www.peopletech.co.in |
From: Gopal k. <gop...@pe...> - 2008-03-31 12:20:38
|
Hi, We have tried and its working with tomcat. On 3/28/08, Gopal krishnan <gop...@pe...> wrote: > > Hi, > Thank you , let me try this with some tweaking. > > On Thu, Mar 27, 2008 at 7:29 PM, 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 > > > > > > > -- > Thank you with regards, > Gopal, > PeopleTech Systems Private Limited > www.peopletech.co.in > -- Thank you with regards, Gopal, PeopleTech Systems Private Limited www.peopletech.co.in |