cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
612
Views
0
Helpful
0
Comments
cdnadmin
Level 11
Level 11
This document was generated from CDN thread

Created by: Sudeera Jayasekara on 17-04-2012 01:13:49 AM
 
Dear all,

I wish to build an application using JTAPI connected to UCCX which will provide an CRM integration that facilitates making calls from agent phones to customer numbers.

I have working code {Attached bellow, which has been referenced} which uses an Agent Extension as the source address.

Although my code works, I have faced an issue while integrating with the CRM. The CRM can only supply the Agent ID, CRM cannot supply Agent Extension. My code works using the agent Extension.

I tried but I was not able to find come up with a solution which will present the agent extension when the Agent ID is passed.


Please help me to find a way to get the Agent extension using the Agent ID.

Thank you in advance.



--Current code which uses agent extension--

import javax.telephony.*;
import javax.telephony.events.*;
import com.cisco.cti.util.Condition;


public class MakeCall {
public MakeCall(String[] args) throws Exception {
String hostname = args[0];
String login = args[1];
String passwd = args[2];
String src = args[3];
String dst = args[4];


/* 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);


/* wait for it to come into service */
final Condition inService = new Condition();
provider.addObserver(new ProviderObserver() {
public void providerChangedEvent(ProvEv[] eventList) {
if (eventList == null)
return;
for (int i = 0; i < eventList.length; ++i) {
if (eventList instanceof ProvInServiceEv) {
inService.set();
}
}
}
});
inService.waitTrue();


/* get an object for the calling terminal */
Address srcAddr = provider.getAddress(src);
srcAddr.addCallObserver(new CallObserver() {
public void callChangedEvent(CallEv[] eventList) {
}
});


/* and make the call */
Call call = provider.createCall();
call.connect(srcAddr.getTerminals()[0], srcAddr, dst);
}


public static void main(String[] args) {
try {
new MakeCall(args);
} catch (Exception e) {
e.printStackTrace();
} finally {
System.exit(0);
}
}
}

Subject: Re: New Message from Sudeera Jayasekara in Cisco JTAPI (JTAPI) - Cisco JTAP
Replied by: Tanner Ezell on 17-04-2012 07:51:57 AM
I would use AXL to query the UCM for the IPCC Extension for the User ID.

On Tue, Apr 17, 2012 at 1:13 AM, Cisco Developer Community Forums <
cdicuser@developer.cisco.com> wrote:

> Sudeera Jayasekara has created a new message in the forum "Cisco JTAPI
> Questions":
>
> --------------------------------------------------------------
>
> Dear all,
>
> I wish to build an application using JTAPI connected to UCCX which will
> provide an CRM integration that facilitates making calls from agent phones
> to customer numbers.
>
> I have working code {Attached bellow, which has been referenced} which
> uses an Agent Extension as the source address.
>
> Although my code works, I have faced an issue while integrating with the
> CRM. The CRM can only supply the Agent ID, CRM cannot supply Agent
> Extension. My code works using the agent Extension.
>
> I tried but I was not able to find come up with a solution which will
> present the agent extension when the Agent ID is passed.
>
>
> Please help me to find a way to get the Agent extension using the Agent ID.
>
> Thank you in advance.
>
>
>
> --Current code which uses agent extension--
>
> import javax.telephony.*;
> import javax.telephony.events.*;
> import com.cisco.cti.util.Condition;
>
>
> public class MakeCall {
> public MakeCall(String[] args) throws Exception {
> String hostname = args[0];
> String login = args[1];
> String passwd = args[2];
> String src = args[3];
> String dst = args[4];
>
>
> /* 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);
>
>
> /* wait for it to come into service */
> final Condition inService = new Condition();
> provider.addObserver(new ProviderObserver() {
> public void providerChangedEvent(ProvEv[] eventList) {
> if (eventList == null)
> return;
> for (int i = 0; i < eventList.length; ++i) {
> if (eventList* instanceof ProvInServiceEv) {
> inService.set();
> }
> }
> }
> });
> inService.waitTrue();
>
>
> /* get an object for the calling terminal */
> Address srcAddr = provider.getAddress(src);
> srcAddr.addCallObserver(new CallObserver() {
> public void callChangedEvent(CallEv[] eventList) {
> }
> });
>
>
> /* and make the call */
> Call call = provider.createCall();
> call.connect(srcAddr.getTerminals()[0], srcAddr, dst);
> }
>
>
> public static void main(String[] args) {
> try {
> new MakeCall(args);
> } catch (Exception e) {
> e.printStackTrace();
> } finally {
> System.exit(0);
> }
> }
> }
> --
> To respond to this post, please click the following link:
>
> <
> http://developer.cisco.com/web/jtapi/forums/-/message_boards/view_message/5474038
> >
>
> or simply reply to this email. *

Subject: RE: Re: New Message from Sudeera Jayasekara in Cisco JTAPI (JTAPI) - Cisco
Replied by: Sudeera Jayasekara on 18-04-2012 09:37:42 PM
Dear Tanner ,
 
Thank you for your valubale reply, but I not familer with AXL scripting. Is there any known resource which might help me.
In the meantime I'm hoping similler can be performed with JTAPI, and any feedback is most valued.
 
Thank you.

 
 
I would use AXL to query the UCM for the IPCC Extension for the User ID.

On Tue, Apr 17, 2012 at 1:13 AM, Cisco Developer Community Forums <
cdicuser@developer.cisco.com> wrote:

> Sudeera Jayasekara has created a new message in the forum "Cisco JTAPI
> Questions":
>
> --------------------------------------------------------------
>
> Dear all,
>
> I wish to build an application using JTAPI connected to UCCX which will
> provide an CRM integration that facilitates making calls from agent phones
> to customer numbers.
>
> I have working code {Attached bellow, which has been referenced} which
> uses an Agent Extension as the source address.
>
> Although my code works, I have faced an issue while integrating with the
> CRM. The CRM can only supply the Agent ID, CRM cannot supply Agent
> Extension. My code works using the agent Extension.
>
> I tried but I was not able to find come up with a solution which will
> present the agent extension when the Agent ID is passed.
>
>
> Please help me to find a way to get the Agent extension using the Agent ID.
>
> Thank you in advance.
>
>
>
> --Current code which uses agent extension--
>
> import javax.telephony.*;
> import javax.telephony.events.*;
> import com.cisco.cti.util.Condition;
>
>
> public class MakeCall {
> public MakeCall(String[] args) throws Exception {
> String hostname = args[0];
> String login = args[1];
> String passwd = args[2];
> String src = args[3];
> String dst = args[4];
>
>
> /* 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);
>
>
> /* wait for it to come into service */
> final Condition inService = new Condition();
> provider.addObserver(new ProviderObserver() {
> public void providerChangedEvent(ProvEv[] eventList) {
> if (eventList == null)
> return;
> for (int i = 0; i < eventList.length; ++i) {
> if (eventList* instanceof ProvInServiceEv) {
> inService.set();
> }
> }
> }
> });
> inService.waitTrue();
>
>
> /* get an object for the calling terminal */
> Address srcAddr = provider.getAddress(src);
> srcAddr.addCallObserver(new CallObserver() {
> public void callChangedEvent(CallEv[] eventList) {
> }
> });
>
>
> /* and make the call */
> Call call = provider.createCall();
> call.connect(srcAddr.getTerminals()[0], srcAddr, dst);
> }
>
>
> public static void main(String[] args) {
> try {
> new MakeCall(args);
> } catch (Exception e) {
> e.printStackTrace();
> } finally {
> System.exit(0);
> }
> }
> }
> --
> To respond to this post, please click the following link:
>
> <
> http://developer.cisco.com/web/jtapi/forums/-/message_boards/view_message/5474038
> >
>
> or simply reply to this email. *


Subject: RE: Re: New Message from Sudeera Jayasekara in Cisco JTAPI (JTAPI) - Cisco
Replied by: David Staudt on 20-04-2012 03:27:30 PM
I'm not familiar with the IPCC APIs, but if the agent ID it provides is the actual UCM user ID, then you can use the AXL <getUser> request - I believe the <primaryExtension><pattern> field will provide the associated DN.
 
Info on the AXL API can be found here: http://developer.cisco.com/web/axl/docs

Subject: RE: Re: New Message from Sudeera Jayasekara in Cisco JTAPI (JTAPI) - Cisco
Replied by: Sudeera Jayasekara on 23-04-2012 02:19:16 AM
Hi David,
Thank you for the information.

Using the information provided by yourself , Tanner and with the help of the following references, I got the bellow listed working code.

http://www.pcnetzwerke.de/cisco-callmanager/cucm-axl-api.html
http://osdir.com/ml/java.sun.jtapi/2006-03/msg00020.html
http://developer.cisco.com/web/axl/forums/-/message_boards/view_message/2896528?_19_tabs1=categories
http://developer.cisco.com/web/axl/forums/-/message_boards/view_message/5445594#_19_message_5411180

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
package com.axl;

import java.io.*;
import java.net.*;
import javax.net.ssl.*;

public class AXLJavaClient {

String xml_res = "";

// Assign Defaults if required
String axl_user = "axluser";
String axl_pass = "axlpass";
String ccm_ip = "192.168.1.100";
String ccm_port = "8443";

public AXLJavaClient(String axl_user, String axl_pass, String ccm_ip,
   String ccm_port) {
  super();
  this.axl_user = axl_user;
  this.axl_pass = axl_pass;
  this.ccm_ip = ccm_ip;
  this.ccm_port = ccm_port;
}

public AXLJavaClient() {
}

public static void main(String[] args) {

  try {
   AXLJavaClient client = new AXLJavaClient();

   client.getUser("user_id");

   // System.out.println(res);

   String telephoneNumber;

   telephoneNumber = client.getElement("telephoneNumber");

   System.out.println(telephoneNumber);
  } catch (Exception e) {
   e.printStackTrace();
  }
}

public String getUser(String userID) {

  String returnString = "";

  byte[] bArray = null; // buffer for reading response from

  Socket socket = null; // socket to AXL server

  OutputStream out = null; // output stream to server

  InputStream in = null; // input stream from server

  String sAXLSOAPRequest = "";

  // HTTPS header and SOAP payload

  String sAXLRequest = null; // will hold only the SOAP payload

  String authorization = axl_user + ":" + axl_pass;

  authorization = new sun.misc.BASE64Encoder().encode(authorization
    .getBytes());

  // Form the http header

  sAXLSOAPRequest = "POST /axl/ HTTP/1.0\r\n";

  sAXLSOAPRequest += "Host:" + ccm_ip + ":" + ccm_port + "\r\n";

  sAXLSOAPRequest += "Authorization: Basic " + authorization + "\r\n";

  sAXLSOAPRequest += "Accept: text/*\r\n";

  sAXLSOAPRequest += "Content-type: text/xml\r\n";

  sAXLSOAPRequest += "SOAPAction: \"CUCMB ver=7.1\"\r\n";

  sAXLSOAPRequest += "Content-length: ";

  // Build the SOAP payload

  sAXLRequest = "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" ";

  sAXLRequest += "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">";

  sAXLRequest += "<SOAP-ENV:Body> <axl:getUser xmlns:axl=\"http://www.cisco.com/AXL/API/7.1\" ";

  sAXLRequest += " xsi:schemaLocation=\"http://www.cisco.com/AXL/API/7.1 http://ccmserver/schema/axlsoap.xsd\" sequence=\"1234\">";

  sAXLRequest += "<userid>" + userID + "</userid>";
  sAXLRequest += "</axl:getUser>";
  sAXLRequest += "</SOAP-ENV:Body>";
  sAXLRequest += "</SOAP-ENV:Envelope>";

  // finish the HTTPS Header

  sAXLSOAPRequest += sAXLRequest.length();

  sAXLSOAPRequest += "\r\n\r\n";
  // now add the SOAP payload to the HTTPS header, which completes the AXL

  // SOAP request

  sAXLSOAPRequest += sAXLRequest;

  try {

   // Implement the certificate-related stuffs required for sending
   // request via https

   X509TrustManager xtm = new MyTrustManager();

   TrustManager[] mytm = { xtm };

   SSLContext ctx = SSLContext.getInstance("SSL");

   ctx.init(null, mytm, null);

   SSLSocketFactory sslFact = (SSLSocketFactory) ctx
     .getSocketFactory();

   socket = (SSLSocket) sslFact.createSocket(ccm_ip,
     Integer.parseInt(ccm_port));

   out = socket.getOutputStream();
   in = socket.getInputStream();

   // send the request to the host
   out.write(sAXLSOAPRequest.getBytes());
   // read the response from the host
   StringBuffer sb = new StringBuffer(2048);
   bArray = new byte[2048];
   int ch = 0;
   int sum = 0;
   while ((ch = in.read(bArray)) != -1) {
    sum += ch;
    sb.append(new String(bArray, 0, ch));
   }
   socket.close();

   socket.close();

   // output the response to the standard output

   // System.out.println(sb.toString());

   returnString = sb.toString();

  } catch (UnknownHostException e) {

   // System.err.println("Error connecting to host: " +
   // e.getMessage());

   return "Error connecting to host: " + e.getMessage();

  } catch (IOException ioe) {

   // System.err.println("Error sending/receiving from server: "
   // + ioe.getMessage());
   returnString = "Error sending/receiving from server: "
     + ioe.getMessage();
   // close the socket

  } catch (Exception ea) {

   // System.err.println("Unknown exception " + ea.getMessage());

   return "Unknown exception " + ea.getMessage();

  }

  finally {

   try {

    if (socket != null)

     socket.close();

   } catch (Exception exc) {

    exc.printStackTrace();

    // System.err.println("Error closing connection to server: "
    // + exc.getMessage());

    returnString = "Error closing connection to server: "
      + exc.getMessage();

   }

  }
  xml_res = returnString;
  return returnString;
}

public String getElement(String element) throws Exception {

  if (xml_res == null || xml_res == "" || xml_res.contains("Error"))
   throw new Exception("Request Faild");

  String[] splitArr = xml_res.split("<" + element + ">");

  splitArr = splitArr[1].split("</" + element + ">");

  return splitArr[0];

}

}


----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

package com.axl;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;

import javax.net.ssl.X509TrustManager;

public class MyTrustManager implements X509TrustManager {

MyTrustManager() {

  // create/load keystore

}

public void checkClientTrusted(X509Certificate chain[], String authType)

throws CertificateException {

}

public void checkServerTrusted(X509Certificate chain[], String authType)

throws CertificateException {

}

public X509Certificate[] getAcceptedIssuers() {

  return null;

}

}


----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Also following are some very good AXL resources.

http://developer.cisco.com/web/axl/overview
http://developer.cisco.com/web/axl/wikidocs/-/wiki/Main/AXL+Operations-by-Release+Matrix
http://www.cisco.com/en/US/docs/voice_ip_comm/cucm/devguide/8_6_1/axl.html
http://developer.cisco.com/web/axl/forums/-/message_boards?_19_mbCategoryId=1052601
http://developer.cisco.com/web/axl/forums/-/message_boards/view_message/4084235


Using the above code and the code I posted first, it is possible to mak calls from agent phones to customer numbers, where the agent id and the customer number are the two input criteria.

Thank you all.
Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community:

Quick Links