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: \"CUCM
B 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.