通过C#中的AXL在Cisco CUCM 11.5中使用updateUser

时间:2018-07-30 13:49:17

标签: c# cucm cisco-axl

我是C#和AXL的新手,所以我试图通过C#中的AXL更新最终用户PIN,但没有成功。我发现的一切都是this

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="http://www.cisco.com/AXL/API/8.5">
   <soapenv:Header/>
   <soapenv:Body>
      <ns:updateUser sequence="?">
         <userid>enduser1</userid>
         <password>123456</password>
         <pin>123456</pin>
      </ns:updateUser>
   </soapenv:Body>
</soapenv:Envelope>

但是如何在C#中使用它呢?是否有C#的指南或代码段?

1 个答案:

答案 0 :(得分:0)

非常简单地通过System.Net.Webclient通过HTTP使用XML字符串,您可以执行以下操作:

using System.Net;
using System;

public class UpdateUser
{
    static public void Main ()
    {
        ServicePointManager.ServerCertificateValidationCallback = (sender, cert, chain, sslPolicyErrors) => true; //Install CUCM cert and remove this for production use
        WebClient client = new WebClient ();
        // Optionally specify an encoding for uploading and downloading strings.
        client.Encoding = System.Text.Encoding.UTF8;
        client.Headers.Add("Authorization","Basic QWRtaW5pc3RyYXRvcjpjaXNjb3BzZHQ=");
        client.Headers.Add("SOAPAction","CUCM:DB ver=11.5 updateUser");
        // Upload the data.
        string reply = client.UploadString ("https://ds-ucm115-1.cisco.com:8443/axl/","<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:ns='http://www.cisco.com/AXL/API/8.5'><soapenv:Header/><soapenv:Body><ns:updateUser><userid>dstaudt3</userid><password>password</password><pin>123456</pin></ns:updateUser></soapenv:Body></soapenv:Envelope>");
        // Disply the server's response.
        Console.WriteLine (reply);
    }
}

您可以通过XML文档编写者或使用SOAP编译器框架获得更抽象的摘要,但是如果您的需求很简单,则字符串操作往往会避免很多开销和复杂性...