05-17-2015 10:49 AM
I am tasked with finding the right API to query current status of endpoints connected to CUCM. By status, I mean "in call, busy, available", etc. and not just "registered".
Based on my reading thus far, there are 2 options:
1. RisPort -> SelectCtiItem method.
2. Device State classes in JTAPI.
For the first method, I tried the following xml request but the answer came back with 0 items:
<soapenv:Header>
<AstHeader xsi:type="soap:AstHeader">
<SessionId xsi:type="xsd:string">1234</SessionId>
</AstHeader>
</soapenv:Header>
<soapenv:Body>
<soap:SelectCtiItem soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<StateInfo xsi:type="xsd:string"></StateInfo>
<CtiSelectionCriteria xsi:type="soap:CtiSelectionCriteria">
<MaxReturnedItems xsi:type="xsd:unsignedInt">200</MaxReturnedItems>
<!-- Line/Device/Provider -->
<CtiMgrClass xsi:type="soap:CtiMgrClass">Device</CtiMgrClass>
<Status xsi:type="soap:CtiStatus">Any</Status>
<NodeName xsi:type="xsd:string"></NodeName>
<SelectAppBy xsi:type="soap:CtiSelectAppBy">AppId</SelectAppBy>
</CtiSelectionCriteria>
</soap:SelectCtiItem>
</soapenv:Body>
</soapenv:Envelope>
2. For the second method, I found this discussion thread:
http://www.velocityreviews.com/threads/cisco-callmanager-4-01sr2-and-jtapi-getstatus.33664/
This leads me to believe there is no straightforward way to find the status of endpoints from CUCM.
Can someone please point out if there is any other way to achieve this or if I am missing something in the 2 methods above.
Thanks in advance
Solved! Go to Solution.
05-19-2015 12:07 PM
Okay, you can create a Call Observer and Terminal Observer and monitor the status of the phone (starting with when you created these observers). You won't necessarily get event names that match your requirements exactly, but you can interpret the events. For example, if you get a "CallActive" and "ConnCreatedEvent Address: (dn)" event, it means someone lifted the receiver or turned on the speaker phone with the given DN/extension.
Download the JTAPI Test Tool for your CUCM version and try a few calls. You can see the events, yourself. I find that's the easiest way to learn how to interpret them.
05-18-2015 07:29 AM
As stated in the thread linked for #2, you can attach a CallObserver with JTAPI and then monitor the events.
I can give you more details when we get our JTAPI working again (a server move disrupted JTAPI on our lab machine).
05-18-2015 09:54 AM
Thanks Nicholas. I will look forward to your input.
05-19-2015 12:07 PM
Okay, you can create a Call Observer and Terminal Observer and monitor the status of the phone (starting with when you created these observers). You won't necessarily get event names that match your requirements exactly, but you can interpret the events. For example, if you get a "CallActive" and "ConnCreatedEvent Address: (dn)" event, it means someone lifted the receiver or turned on the speaker phone with the given DN/extension.
Download the JTAPI Test Tool for your CUCM version and try a few calls. You can see the events, yourself. I find that's the easiest way to learn how to interpret them.
05-19-2015 12:31 PM
Thanks Nicholas. The following code with addition to your suggestions should do the trick:
(Instead of doing anything inside the observers, I am polling the device status every few seconds to get the latest.)
/* start up JTAPI */
JtapiPeer peer = JtapiPeerFactory.getJtapiPeer(null);
/* connect to the provider */
String providerString = hostname;
providerString += ";login=" + login;
providerString += ";passwd=" + passwd;
Provider provider = peer.getProvider(providerString);
CiscoProvider ciscoProvider = (CiscoProvider) provider;
final Condition inService = new Condition();
ciscoProvider.addObserver(new ProviderObserver() {
public void providerChangedEvent(ProvEv[] eventList) {
if (eventList == null)
return;
for (int i = 0; i < eventList.length; ++i) {
if (eventList[i] instanceof ProvInServiceEv) {
inService.set();
}
}
}
});
inService.waitTrue();
Terminal[] terms = ciscoProvider.getTerminals();
for (int i = 0; i < terms.length; i++) {
CiscoTerminal term = (CiscoTerminal) terms[i];
if (term.isRestricted() || !term.isRegistered())
{
System.out.println(term + "; Type = " + term.getTypeName() + "; Restricted = "
+ term.isRestricted() + "; Registered = " + term.isRegistered());
}
if (!term.isRestricted()) {
term.addObserver(new CiscoTerminalObserver() {
@Override
public void terminalChangedEvent(TermEv[] arg0) {
}
});
term.addCallObserver(new CallObserver() {
@Override
public void callChangedEvent(CallEv[] arg0) {
}
});
}
}
while(true){
Thread.sleep(5000);
for (int i = 0; i < terms.length; i++) {
CiscoTerminal term = (CiscoTerminal) terms[i];
if (!term.isRestricted() && term.isRegistered())
{
PrintTerminalStatus(term);
}
}
}
//provider.shutdown();
public void PrintTerminalStatus(CiscoTerminal term)
{
int termstate = term.getState();
if (termstate == term.IN_SERVICE) {
System.out.println(term.getTypeName() + "(" + term + ") is in service");
try {
int devicestate = term.getDeviceState();
System.out.println("Device state for " + term + "= " + devicestate);
if (devicestate == term.DEVICESTATE_ACTIVE) {
System.out.println("DEVICESTATE_ACTIVE");
} else if (devicestate == term.DEVICESTATE_ALERTING) {
System.out.println("DEVICESTATE_ALERTING");
} else if (devicestate == term.DEVICESTATE_HELD) {
System.out.println("DEVICESTATE_HELD");
}else if (devicestate == term.DEVICESTATE_IDLE) {
System.out.println("DEVICESTATE_IDLE");
}else if (devicestate == term.DEVICESTATE_UNKNOWN) {
System.out.println("DEVICESTATE_UNKNOWN");
}else if (devicestate == term.DEVICESTATE_WHISPER) {
System.out.println("DEVICESTATE_WHISPER");
}else {
System.out.println("Device State = Other");
}
} catch (Exception ex) {
System.out.println(ex);
} finally {
}
} else if (termstate == term.OUT_OF_SERVICE) {
System.out.println(term.getTypeName() + "(" + term + ") is out of service; Registered = " + term.isRegistered());
} else {
System.out.println("Other");
}
}
05-20-2015 12:18 PM
Excellent! Thanks very much for sharing your code. It should help others looking to do the same or similar things!
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide