我正在使用cisco CUCM AXL API & C#,
我想更改 description's phone
。我的代码没有问题,但设备手机仍然有最近的说明,当我访问思科管理时,我找到新的说明但在设备上。 知道为什么吗?
这是我的代码:
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;
}
}
答案 0 :(得分:2)
我找到了,我必须像CUCM一样应用配置。
我的代码用于更改手机中的数据,但如果我们需要应用新配置,我们应该调用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>";
答案 1 :(得分:0)
对于CUCM中的所有设备,要将配置应用于终端设备,您需要在apply
通话后使用restart
,reset
或update
方法。
增加订单影响:
apply
会在设备上显示行级更改。restart
刷新所有设备设置reset
刷新所有设备设置,包括其IP和TFTP设置的整个刷新。但它不会删除手机上的证书。它可能导致几分钟的连接丢失(包括链接到它的任何PC)&gt;
如果您不喜欢自己的工作,请在工作时间内执行此操作。在您的情况下,您只是更改了手机的lines
属性,因此使用updatePhone
,然后applyPhone
或restartPhone
可以达到预期的效果。< / p>