cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1133
Views
5
Helpful
0
Replies
Beginner

Cisco CUCM Query with C#

Hi i have a problem using C# for querying CUCM, i got an error:


System.Net.WebException: The remote server returned an error: (599).

   at System.Net.HttpWebRequest.GetResponse()

Here is my code:

HttpWebRequest req = (HttpWebRequest)WebRequest.Create(@"https://172.20.0.101:8443/axl/");

            req.ProtocolVersion = HttpVersion.Version10;

            req.Method = "POST";

            req.Host = "172.20.0.101:8443";

            req.ProtocolVersion = System.Net.HttpVersion.Version10;

           

            req.ContentType = "text/xml";

            req.Accept = "text/xml";

            req.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(System.Text.ASCIIEncoding.ASCII.GetBytes("test:admin123")));

            req.Headers.Add("SOAPAction:CUCM:DB ver=10.5");

            req.Credentials = CredentialCache.DefaultCredentials;

            string mes;

           mes = "<SOAP-EN:Envelope xmlns:SOAP-EN=";

            mes += "\"http://schemas.xmlsoap.org/soap/envelope/\"";

            mes += "xmlns: ns =\"http://www.cisco.com/AXL/API/10.5\">";

            mes += "<SOAP-EN:Header/>";

            mes += "<SOAP-EN:Body>";

            mes += "<ns:executeSQLQuery sequence = \"1\">";

            mes += "<sql>SELECT * FROM Device</sql>";

            mes += "</ns:executeSQLQuery ></SOAP-EN:Body></SOAP-EN:Envelope>";

            System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate (object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { return true; }  ;

            byte[] buffer = System.Text.Encoding.UTF8.GetBytes(mes);

            req.ContentLength = buffer.Length;

            Stream s = req.GetRequestStream();

           // s.Position = 0;

            s.Write(buffer, 0, mes.Length);

            s.Close();

            try

            {

                WebResponse resp = req.GetResponse();

               

                s = resp.GetResponseStream();

                StreamReader sr = new StreamReader(s, Encoding.UTF8);

                string outputString = sr.ReadToEnd(); //Just output XML response

                richTextBox1.Text = outputString;

                sr.Close();

                s.Close();

                resp.Close();

            }

            catch (Exception ex)

            {

                string excep = ex.ToString();

                richTextBox1.Text = excep;

            }

Everyone's tags (4)
CreatePlease to create content