2

I'm working with cisco CUCM AXL API & C#,

I want to change description's phone.There is no problem in my code ,but the device phone still with the recent description , when i access to Cisco mangement , i find the new description but on on the device . Any idea why ?

This my code :

    private bool subUpdateDevice(string _pattern, string _name, string _device, int _index)
    {

        HttpWebRequest req = (HttpWebRequest)WebRequest.Create(@"https://xxx.xxx.xxx.xxx:8443/axl/");
        req.ProtocolVersion = HttpVersion.Version10;

        req.Method = "POST";
        req.Host = "xxx.xxx.xxx.xxx: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("XXXXX:xxxxx")));

        string strAXLRequest = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" ";
        strAXLRequest += "xmlns:ns=\"http://www.cisco.com/AXL/API/10.5\">";
        strAXLRequest += "<soapenv:Header/><soapenv:Body>";
        strAXLRequest += "<ns:updatePhone>";
        strAXLRequest += "<name>" + _device + "</name>";
        strAXLRequest += "<lines><line>";
        strAXLRequest += "<index>" + _index + "</index>";
        strAXLRequest += "<display>" + _name + "</display>";
        strAXLRequest += "<dirn>";
        strAXLRequest += "<pattern>" + _pattern + "</pattern>";
        strAXLRequest += "</dirn>";
        strAXLRequest += "<displayAscii>" + _name + "</displayAscii>";
        strAXLRequest += "</line></lines></ns:updatePhone>";
        strAXLRequest += "</soapenv:Body></soapenv:Envelope>";

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

        req.ContentLength = strAXLRequest.Length;
        try
        {
            Stream s = req.GetRequestStream();

            byte[] buffer = System.Text.Encoding.UTF8.GetBytes(strAXLRequest);
            s.Write(buffer, 0, strAXLRequest.Length);
            s.Close();
            try
            {
                WebResponse resp = req.GetResponse();

                s = resp.GetResponseStream();
                StreamReader sr = new StreamReader(s);
                string outputString = sr.ReadToEnd();

                sr.Close();
                s.Close();
                resp.Close();


                if (outputString.Contains("updatePhoneResponse"))
                {
                    return true;
                }
                else return false;
            }
            catch (Exception ex)
            {
                string excep = ex.ToString();
                return false;
            }
        }
        catch (WebException wex)
        {
            string excep = wex.ToString();


            return false;
        }
        catch (NotSupportedException nex)
        {
            string excep = nex.ToString();

            return false;
        }
        catch (ObjectDisposedException oex)
        {
            string excep = oex.ToString();

            return false;
        }
        catch (ProtocolViolationException pex)
        {
            string excep = pex.ToString();


            return false;
        }

    }
Zied R.
  • 4,964
  • 2
  • 36
  • 67

2 Answers2

3

I found it , I must apply config as in CUCM .

My code is for changing data in phone , but if we need to apply the new config we should call ApplyPhone .. and finallay it works for me : this is the code (just changing the strAXLRequest

      string strAXLRequest = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" ";
        strAXLRequest += "xmlns:ns=\"http://www.cisco.com/AXL/API/10.5\">";
        strAXLRequest += "<soapenv:Header/><soapenv:Body>";
        strAXLRequest += "<ns:applyPhone>";
        strAXLRequest += "<name>" + _device + "</name>";
        strAXLRequest += "</ns:applyPhone>";
        strAXLRequest += "</soapenv:Body></soapenv:Envelope>";
Zied R.
  • 4,964
  • 2
  • 36
  • 67
2

For all devices in CUCM, to apply your configuration to an end device, you either need to use an apply, restart or reset method after your update call.

In increasing order impact:

  • apply makes line-level changes appear on the device.
  • restart refreshes all device settings
  • reset refreshes all device settings, including an entire refresh of its IP and TFTP settings. It does not remove certificates on the phone though. It can cause several minutes of loss of connectivity (including any PC chained to it)> Mass execute this during business hours if you don't like your job.

In your case, you are only making changes to the phone's lines attributes, so using updatePhone, followed by applyPhone or restartPhone would achieve the desired effect.

jonathan
  • 784
  • 1
  • 10
  • 27