<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<TITLE>Messaggio</TITLE>
<META content="MSHTML 6.00.2900.2627" name=GENERATOR></HEAD>
<BODY>
<DIV><FONT face=Arial size=2><SPAN class=914154208-14062005>The code is based on
the sample program provided with asterisk-java tutorial, lightly customized to
match my environment, and included in a jbuilder project; the class
ManagerConnection belongs to asterisk-java-0.1.jar.</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN class=914154208-14062005>I think my problem
is in your sentence: 'how is reading the response'; I found no other reference,
in tutorial or in javadocs, about the way to read it; it may be that the
ManagerResponse refers to the command itself, which effectively ends
with success, and does not contain the extension status info: but then,
where and how have I to search that data?</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=914154208-14062005></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=914154208-14062005>Anyway, this is the
complete code of the program which should inquiry the status of an extension,
together with its printout. </SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN class=914154208-14062005>Newly
thanks,</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=914154208-14062005>Franco.</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=914154208-14062005></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN
class=914154208-14062005>===================<BR>=== SOURCE CODE
===<BR>===================<BR>package astpac;</SPAN></FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=914154208-14062005>import
java.io.*;<BR>import
net.sf.asterisk.manager.AuthenticationFailedException;<BR>import
net.sf.asterisk.manager.ManagerConnection;<BR>import
net.sf.asterisk.manager.ManagerConnectionFactory;<BR>import
net.sf.asterisk.manager.TimeoutException;<BR>import
net.sf.asterisk.manager.action.ExtensionStateAction;<BR>import
net.sf.asterisk.manager.response.ManagerResponse;</SPAN></FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=914154208-14062005>public class
ProActions<BR>{<BR> private ManagerConnection
managerconnection;<BR>
/*************************************************/<BR> public
ProActions() throws IOException<BR>
{<BR> try
{<BR> ManagerConnectionFactory factory
= new ManagerConnectionFactory();<BR>
this.managerconnection =
factory.getManagerConnection("172.16.1.151","admin","amp111");<BR>
}<BR> catch(IOException ie)
{<BR> System.out.println(ie.toString()
+ "[ProActions]");<BR>
}<BR> catch(Exception e)
{<BR> System.out.println(e.toString()
+ " [ProActions]");<BR> }<BR>
}<BR>
/*************************************************/<BR> public
void run() throws IOException,
AuthenticationFailedException,<BR>
TimeoutException<BR> {<BR> try
{<BR> ManagerResponse
managerresponse;<BR>
managerconnection.login();<BR>
ExtensionStateAction extensionstateaction = new
ExtensionStateAction();<BR>
extensionstateaction.setExten("203");<BR>
managerresponse =
managerconnection.sendAction(extensionstateaction,30000);<BR>
System.out.println(managerresponse.getResponse());<BR>
}<BR>
managerconnection.logoff();<BR>
}<BR> catch (Exception e)
{<BR>
System.out.println(e.toString());<BR>
}<BR> }<BR>
/*************************************************/<BR> public
static void main(String[] args) throws Exception<BR>
{<BR> ProActions proactions = new
ProActions();<BR>
proactions.run();<BR> }<BR>}</SPAN></FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2><SPAN
class=914154208-14062005>=======================================<BR>=== OUTPUT
GENERATED BY THE PROGRAM
===<BR>=======================================<BR> <BR>C:\JBuilder9\jdk1.4\bin\javaw
-classpath </SPAN></FONT><FONT face=Arial size=2><SPAN
class=914154208-14062005>"C:\swdev\agsm\astproof\classes;C:\swdev\agsm\asterisk-java-0.1\asterisk-java-0.1.jar;C:\JBuilder9\jdk1.4\demo\jfc\Java</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=914154208-14062005>2D\Java2Demo.jar;C:\JBuilder9\jdk1.4\demo\plugin\jfc\Java2D\Java2Demo.jar;C:\JBuilder9\jdk1.4\jre\lib\charsets.jar;C:\J</SPAN></FONT><FONT
face=Arial size=2><SPAN
class=914154208-14062005>Builder9\jdk1.4\jre\lib\ext\dnsns.jar;C:\JBuilder9\jdk1.4\jre\lib\ext\ldapsec.jar;C:\JBuilder9\jdk1.4\jre\lib\ext\local</SPAN></FONT><FONT
face=Arial size=2><SPAN
class=914154208-14062005>edata.jar;C:\JBuilder9\jdk1.4\jre\lib\ext\sunjce_provider.jar;C:\JBuilder9\jdk1.4\jre\lib\im\indicim.jar;C:\JBuilder9\j</SPAN></FONT><FONT
face=Arial size=2><SPAN
class=914154208-14062005>dk1.4\jre\lib\jaws.jar;C:\JBuilder9\jdk1.4\jre\lib\jce.jar;C:\JBuilder9\jdk1.4\jre\lib\jsse.jar;C:\JBuilder9\jdk1.4\jre</SPAN></FONT><FONT
face=Arial size=2><SPAN
class=914154208-14062005>\lib\rt.jar;C:\JBuilder9\jdk1.4\jre\lib\sunrsasign.jar;C:\JBuilder9\jdk1.4\lib\dt.jar;C:\JBuilder9\jdk1.4\lib\htmlconve</SPAN></FONT><FONT
face=Arial size=2><SPAN
class=914154208-14062005>rter.jar;C:\JBuilder9\jdk1.4\lib\tools.jar"
-Xdebug -Xnoagent -Djava.compiler=NONE </SPAN></FONT><FONT face=Arial
size=2><SPAN
class=914154208-14062005>-Xrunjdwp:transport=dt_socket,address=francobaldi-xp:1207,suspend=y
astpac.ProActions <BR>14-giu-2005 10.24.49
net.sf.asterisk.util.impl.JavaLoggingLog info<BR>INFO: Connecting to
172.16.1.151 port 5038<BR>14-giu-2005 10.24.50
net.sf.asterisk.util.impl.JavaLoggingLog info<BR>INFO: Connected via Asterisk
Call Manager/1.0<BR>14-giu-2005 10.24.50
net.sf.asterisk.util.impl.JavaLoggingLog info<BR>INFO: Successfully logged
in<BR>14-giu-2005 10.24.50 net.sf.asterisk.util.impl.JavaLoggingLog
info<BR>INFO: Reached end of stream, terminating
reader.<BR>net.sf.asterisk.manager.response.ManagerResponse: actionId='null';
message='Extension Status'; response='Success'; </SPAN></FONT><FONT face=Arial
size=2><SPAN class=914154208-14062005>uniqueId='null';
systemHashcode=751354<BR>14-giu-2005 10.24.50
net.sf.asterisk.util.impl.JavaLoggingLog info<BR>INFO: Closing
socket.<BR></SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=914154208-14062005></SPAN></FONT> </DIV></BODY></HTML>