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

    }
4

2 回答 2

3

我找到了,我必须像在 CUCM 中一样应用配置。

我的代码用于更改手机中的数据,但如果我们需要应用新配置,我们应该调用ApplyPhone.. 和 finallay 它对我有用:这是代码(只是更改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>";
于 2015-04-16T07:30:30.083 回答
2

对于 CUCM 中的所有设备,要将配置应用到终端设备,您需要在调用后使用applyrestartreset方法update

在增加订单影响:

  • apply使行级更改出现在设备上。
  • restart刷新所有设备设置
  • reset刷新所有设备设置,包括对其 IP 和 TFTP 设置的完整刷新。但它不会删除手机上的证书。它可能会导致几分钟的连接丢失(包括链接到它的任何 PC)> 如果您不喜欢您的工作,请在工作时间大规模执行此操作。

在您的情况下,您只是对手机的lines属性进行更改,因此使用updatePhone, 后跟applyPhoneorrestartPhone会达到预期的效果。

于 2018-04-15T10:24:27.107 回答