Cisco Unified Call Manager (CUCM) AXL API 更新 Phone 成功但我的设备没有变化

Cisco Unified Call Manager (CUCM) AXL API Update Phone successed but no change in my device

我正在与 cisco CUCM AXL API & C#,

合作

我想更改description's phone。我的代码没有问题,但是设备phone仍然是最近的描述,当我访问对于 Cisco management,我在设备上找到了新的描述。 知道为什么吗?

这是我的代码:

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

    }

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

我的代码用于更改 phone 中的数据,但如果我们需要应用新配置,我们应该调用 ApplyPhone .. 最后它对我有用: 这是代码(只是改变 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>";

对于 CUCM 中的所有设备,要将您的配置应用到终端设备,您需要在 [=13= 之后使用 applyrestartreset 方法] 称呼。

按递增顺序影响:

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

在您的例子中,您只是在更改 phone 的 lines 属性,因此使用 updatePhone,然后是 applyPhonerestartPhone 会达到预期的效果。