AXL Services Always Return Null in C#.NET

Unanswered Question
Mar 25th, 2008
User Badges:

I downloaded the AXL SQL Toolkit, and I am always getting a null result set. Below is my C#.NET code:

AXLAPIService axl = new AXLAPIService("ipaddress", "user", "password");

ExecuteSQLQueryReq request = new ExecuteSQLQueryReq();

ExecuteSQLQueryRes result = new ExecuteSQLQueryRes();

request.sql = "SELECT * FROM Device ";

result = axl.executeSQLQuery(request);

I also get a null result when calling any other AXL service, such as GetUser.

I have tried using BruteForcePolicy and Expect100Continue = false as well, but I still get a null result. I know that my user and password are authenticating okay, and I know that my request is being "understood", because I get an exception if my SQL statement is incorrect, for example.

  • 1
  • 2
  • 3
  • 4
  • 5
Overall Rating: 0 (0 ratings)
stephan.steiner Fri, 03/28/2008 - 06:16
User Badges:
  • Silver, 250 points or more

sounds like yet another problem with the manually hacked wsdl file - however, have you tried

"SELECT * FROM device"? None of the table names use capital letters, and it's a linux box so it's case sensitive.

kbarker302 Fri, 03/28/2008 - 07:03
User Badges:

Yes, I am using the hacked wsdl file, if by that you mean having made the various changes specified in the readme file. That's a good point about it being a linux box, but I tried the select statement above and got the same result.

I have also tried doing an XML push instead of using the proxy class, and over 99% of the time I have gotten a 401 - Unauthorized message doing that -- however, for a very brief window yesterday (perhaps 3-5 requests over just a few minutes) I actually got some results back that I could clearly see in Visual Studio. Here's the code:

string AXLRequest;

string type = "getUser";

string param = "myuserid";

string Sequence = "1";

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

AXLRequest += " ";

AXLRequest += "\" xsi:schemaLocation=\" https://myip/schema/axlsoap.xsd\" sequence=\"" + Sequence + "\"> ";

AXLRequest += param + " ";

AXLRequest += " ";

AXLRequest += " ";

AXLRequest += " ";

ServicePointManager.Expect100Continue = false;

String strUriHttps = @"https://myip:8443/axl";

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

oWRequest.Method = "POST";

oWRequest.ContentType = "text/xml";

String AXLHeader = null;

String Auth = "myaxluser" + ":" + "password";

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

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

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

AXLHeader += "Authorization: Basic " + Auth + "\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: " + AXLRequest.Length.ToString() + "\r\n\r\n";

AXLHeader += AXLRequest;

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

String rep = readStream.ReadToEnd();

I know about appending the equal signs to the password for authentication and that hasn't made a difference, but I'm curious as to how the same code appeared to work for a very brief window.

stephan.steiner Fri, 03/28/2008 - 10:15
User Badges:
  • Silver, 250 points or more

Umm.. is it just me or are you only sending the AXLHeader to the callmanager?

And I'm not sure you need all those headers.. my colleague is currently adapting our connector class to ccm 6.1.1 and we did a few test runs, still using the same old code as in ccm 4.1.3 to send an AXL request. It's java, but it's easy enough to switch to C#:

String soaprequest = "\" xmlns:xsi=\"\" xmlns:xsd=\"\">\n";

soaprequest += "\n";

soaprequest += "\" xsi:schemaLocation=\"\" xsi:type=\"XRequest\" sequence=\"1234\">\n";

soaprequest += axlParams + "\n";

soaprequest += "\n";

soaprequest += "\n";

soaprequest += "";

tracer.Trace("AXL Request: " + axlRequest + "Parameters:\r\n" + axlParams, 5);

URL url = new URL(this.apiPath);

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




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

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

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



PrintWriter pout = new PrintWriter(new OutputStreamWriter(conn.getOutputStream()), true);



int status = conn.getResponseCode();

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

kbarker302 Mon, 04/07/2008 - 05:52
User Badges:

(To answer your question, both the header and the request are getting sent. The AXLRequest variable gets concatenated to the AXLHeader variable.)

Thanks for the Java sample. Fyi, when I go to http://myip/axl in the browser, I get a certificate error. We then downloaded the certificate and installed it using keytool, but we are getting various errors related to the certificate that's preventing the SOAP request from going through.

pklos Mon, 04/07/2008 - 06:39
User Badges:
  • Silver, 250 points or more

Add this line before creating HttpWebRequest:

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




kbarker302 Tue, 04/08/2008 - 06:06
User Badges:

Thanks--I added that line, and I got the same results as described in my second post. I was able to get results successfully at first, but after about 10 requests or so, I got a 401 - Unauthorized error repeatedly after that. Today I am strictly getting the 401. The results are extremely random.


This Discussion