Retrieve Data from CUCM 6.x in an XML file using WebService

Unanswered Question
Jul 15th, 2008


Can anyone please help me on how to retrieve data from CUCM database using a WebService , e.g. User information such as First Name, Last Name, Phone Extension and Department in an XML format and display that information on a webpage in ASP.NET2.0(C#).


I have this problem too.
0 votes
  • 1
  • 2
  • 3
  • 4
  • 5
Overall Rating: 0 (0 ratings)
msabir Tue, 07/15/2008 - 20:03

There is sample code in SDK, both for C# and Java. You basically want to use RisPort web service and it's WSDL is also available on CUCM itslef. I am not much familiar with ASP.NET, but in Eclipse/NetBeans, all you have to do is to load WSDL file and it creates all the code for you. You can just use the stub classes to call the web service. There is probably similar or even easier way in ASP.NET/VisualStudio.Net.

kevindesai Wed, 07/16/2008 - 16:49

Thanks msabir for your help.

I have already installed WSDL for .NET and also made the following changes based on the documentation (CUCM 6.0)

1. created a public class derived from System.Net.ICertificatePolicy (Method of BruteForcePolicy )


public bool CheckValidationResult(System.Net.ServicePoint sp, System.Security.Cryptography.X509Certificates.X509Certificate cert,

System.Net.WebRequest request, int problem)


return true;



2. Modified the AXLAPIService constructor


public AXLAPIService(string ccmIp, string user, string password) {

System.Net.ServicePointManager.CertificatePolicy = new BruteForcePolicy();

this.Url = "https://" + ccmIp + ":8443/axl/";



3. Overriden the GetWebRequest method


protected override System.Net.WebRequest GetWebRequest(Uri uri){

System.Net.HttpWebRequest request = (System.Net.HttpWebRequest)base.GetWebRequest(uri);

if (this.PreAuthenticate){

System.Net.NetworkCredential nc = this.Credentials.GetCredential(uri, "Basic");

if (nc != null) {

byte[] credBuf = new System.Text.UTF8Encoding().GetBytes(nc.UserName + ":" + nc.Password);

request.Headers["Authorization"] = "Basic" + Convert.ToBase64String(credBuf);



return request;



Also made changes in

public XUserUserGroupUserRolesUserRole[] userRoles;

The following function call instantiate the AXLAPIService object, just to check if there is a connection between the client (webpage) and CUCM Database.

public void axlTest()


sUserID = txtUserID.Text.Trim().ToString();

sPassword = txtPassword.Text.Trim().ToString();

AXLAPIService oAXL = new AXLAPIService(ccmServer, sUserID, sPassword);

ListDeviceByNameAndClassReq phoneByName = new ListDeviceByNameAndClassReq();

phoneByName.searchString = "SEP%";

ListDeviceResDevice[] phones = oAXL.listDeviceByNameAndClass(phoneByName).@return;

foreach (ListDeviceResDevice phone in phones) {





When I debugg the above code I get the message saying "Connecting to the server machine failed. This may be because the machine doesn't exist or a firewall is preventing communication to the remote computer".

However I can able to access the web admin interface from the same machine. And also able to telnet the remote machine.

Could you please help me identify where exactly the problem is or what is it that I'm doing wrong?

Thanks a lot!

stephan.steiner Thu, 07/17/2008 - 00:51

Can you start Wireshark and trace what is happening communication wise? When there's a connect problem that's usually an easy way to figure out any errors

kevindesai Sun, 07/20/2008 - 21:31

Thanks Stephan for your reply.

The Call Manager Host is on the same hub as the client machine (ASP.NET2.0). I can access the web admin page and also I've tried telnet the CUCM host machine on port 8443 and its working fine.

stephan.steiner Mon, 07/21/2008 - 03:27

I'd still do the wireshark trace.. by the looks of it there won't be any connection setup at all and you'd see that right away with a wireshark trace.

kevindesai Mon, 07/21/2008 - 20:23

I've tried with the wireshark, and it looks like there is a connection between the client(source) and cucm host(destination).

What I'd like to point out is, CUCM is installed on a VMWare which actually runs on a Windows XP machine. I have set the static IP for the VMWare( and the actual machine's IP is ( When I telnet/ping/wireshark on it is working fine. I have disabled the proxy settings and in the windows hosts file entered so that it connects to the cucm host machine, still I'm getting the error message BAD REQUEST 400.

stephan.steiner Tue, 07/22/2008 - 03:19

Well.. a 400 response is something else entirely than being unable to connect ;)

Now the best thing would be to dump the soap message and verify that it's valid (you can easily do that by saving the text as xml file and opening it in internet explorer), then verify that the syntax is valid (verify against the schema).

Also, there are AXL traces on the CCM which you can download using the RTMT (that's one of the plugins you can download from ccmadmin). If all that tells you nothing, ask the guy who set up your CCM as this part is more in their domain.

kevindesai Tue, 07/22/2008 - 21:44

I've tried with the SOAP Request and I'm still getting the same error. "BAD REQUEST 400".

I've tried with the following code:


public string SOAPRequest() {

string strAXLRequest = string.Empty;

string AXLHeader = string.Empty;

string strAuthentication = string.Empty;

string strUriHttps = @"https://ccmserver:8443/axl";

string rep = string.Empty;

try {

ServicePointManager.ServerCertificateValidationCallback += delegate { return true; };

HttpWebRequest oWRequest = (HttpWebRequest)HttpWebRequest.Create(new Uri(strUriHttps));

oWRequest.Method = "POST";

oWRequest.ContentType = "text/xml";

strAuthentication = txtUserID.Text.Trim() + ":" + txtPassword.Text.Trim();

strAXLRequest = "\" xmlns:xsi=\"\" xmlns:xsd=\"\"> ";

strAXLRequest += " ";

strAXLRequest += "\" xsi:schemaLocation=\" http://ccmserver/schema/axlsoap.xsd\" sequence=\"1234\"> ";

strAXLRequest += "SEP001CEEEBCEBE ";

strAXLRequest += " ";

strAXLRequest += " ";

strAXLRequest += " ";

strAuthentication = Convert.ToBase64String(Encoding.ASCII.GetBytes(strAuthentication));

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

AXLHeader += "Host:ccmserver:8443\r\n";

AXLHeader += "Authorization: Basic " + strAuthentication + "\r\n";

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

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

AXLHeader += "SOAPAction: \"CUCM:DB ver=6.0\"\r\n";

AXLHeader += "Content-length: " + strAXLRequest.Length.ToString() + "\r\n\r\n";

AXLHeader += strAXLRequest;

Stream stream = oWRequest.GetRequestStream();

stream.Write(System.Text.Encoding.ASCII.GetBytes(AXLHeader), 0, AXLHeader.Length);


HttpWebResponse oWResponse = (HttpWebResponse)oWRequest.GetResponse();

Stream recStream = oWResponse.GetResponseStream();

StreamReader readStream = new StreamReader(recStream, Encoding.UTF8);

rep = readStream.ReadToEnd();


catch (Exception ex){

lblMessage.Text = ex.Message.ToString();


return rep;


kevindesai Thu, 07/24/2008 - 04:48

now I'm getting 401 error. I'm trying with the code copied in my previous post.

stephan.steiner Thu, 07/24/2008 - 06:07

Well.. 401 is good.. that means the login/password you use is not correct. To get started, use the same credentials as you use to login to ccmadmin to administrate the server.

kevindesai Thu, 07/24/2008 - 06:43

I'm using the same login for ccmadmin i.e. the one for Web Admin Interface.

could you please help what is the following line for

because in the CUCM user guide sample there is some key is given ,


"Authorization: Basic " + strAuthentication + "\r\n"; --- [strAuthentication is username and passcode]


and also do I have to provide https://ccmserverIP:8443/schema/axlsoap.xsd

in the following statement or only http://ccmserverIP/schema/axlsoap.xsd

"\" xsi:schemaLocation=\" http://ccmserver/schema/axlsoap.xsd\" sequence=\"1234\"> ";

really appreciate your efforts.


stephan.steiner Thu, 07/24/2008 - 23:00

You don't need to add the port.. I know you're not using Java but since it's similar here are my two methods that generate the data to be sent, and send the data.. perhaps you can adapt them.

You'll see that I'm not really sending the same thing as in the developer guide (the guide seems a bit weird that way.. I just took the working axl class from the ip phone sdk and adapted and optimized it until I got to this point here.. I've used that code for various ccm5 and 6 releases and it always works fine).

public String sendRequest(String axlRequest, String axlParams, boolean utf8) throws CommunicationException


StringBuffer HTTPBuffer = new StringBuffer();



String sAXLRequest = generateAXLRequest(axlRequest, axlParams);

tracer.Trace("AXL request: " + sAXLRequest, 5);

URL url = new URL(this.apiPath);

HttpsURLConnection conn = (HttpsURLConnection)url.openConnection ();





conn.setRequestProperty("Content-Type", "text/xml");

conn.setRequestProperty("Content-Length", "" + sAXLRequest.length());

conn.setRequestProperty("Authorization", "Basic " + this.authentication);

String databaseVersion = getDatabaseVersion(this.getVersion());

if (databaseVersion != null)

conn.setRequestProperty("SOAPAction", databaseVersion);


PrintWriter pout = new PrintWriter(new OutputStreamWriter(conn.getOutputStream(), "UTF-8"), true);



int status = conn.getResponseCode();

if (status >= 400) // we have an error (30x should be handled since we set followredirect)



if (status == 503) // we sent too many requests in too little time




System.err.println("Got 503 response to AXL request, sleeping for 10 seconds before retrying.");

Thread.sleep(10000); // sleep for ten seconds, then try again

return sendRequest(axlRequest, axlParams, utf8);


catch (InterruptedException ex)


throw new CommunicationException("Error executing POST Request. Status: " + status + " error: " + conn.getResponseMessage());




throw new CommunicationException("Error executing POST Request. Status: " + status + " error: " + conn.getResponseMessage());


String response = readServerResponse(conn.getInputStream(), true);

return processResponse(response, sAXLRequest);


catch (MalformedURLException m)


throw new CommunicationException("Malformed url: " + this.apiPath + "\r\nOriginal message: " + m.getMessage());


catch (IOException i)


throw new CommunicationException("IO problem: " + i.getMessage());



stephan.steiner Thu, 07/24/2008 - 23:00

And here's the second method (had to remove it due to the post length limit this board has).

protected String generateAXLRequest(String request, String parameters)


StringBuilder soaprequest = new StringBuilder("\" ");

soaprequest.append("xmlns:xsi=\"\" xmlns:xsd=\"\"> ");

soaprequest.append("\" ");

soaprequest.append(" xsi:schemaLocation=\" http://ccmserver/schema/axlsoap.xsd\" ");

soaprequest.append("sequence=\"1234\"> " + parameters);

soaprequest.append(" ");

//tracer.Trace("AXL Request: " + request + "Parameters:\r\n" + parameters, 5);

return soaprequest.toString();


kevindesai Tue, 07/29/2008 - 15:38


Problem solved. I did get the response back from the CUCM finally. :-)

I have also notinced one strange behavior, sometimes it gives 401 error and when I click the SEND REQUeST button for several times (avg 5 times) it displays the content [with the same userid and passcode], I wonder why??

And how do I send multiple SQL statements in one SOAP Request? And do you have any idea regarding the SQL on CUCM or where can I get documents on SQL on CUCM?

I really appreciate your help and effrots.



stephan.steiner Tue, 07/29/2008 - 23:23

This page (make sure you bookmark it.. it is extremely useful) has all programming guides for CCM, and amongst them, a complete DB schema:

You cannot send multiple statements concurrently. Back with CCM4 I did try some funky SQL Server stuff (iterating through cursors and the likes) but unfortunately it was blocked. While the DB can handle it, axl is rather limited.

I don't know about the 401.. there's a throttling mechanism (described in the developer guide.. it responds with 503 when you need to wait before making any other writing query) but it doesn't use that error code. You might want to look at the axl traces from the ccm to see what is going wrong.


This Discussion