updateUser in Cisco CUCM 11.5 via AXL in C#

1.2k views Asked by At

I'm new to C# and AXL, so I'm trying to update the End User PIN via AXL in C# without success. Everything what I have found is 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>

But how can use this in C#? Is there a guide or code snippet for C#?

1

There are 1 answers

0
David Staudt On

Very simply using XML strings over HTTP with System.Net.Webclient, you can do something like:

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

You can get fancier/more abstract by an XML document writer, or using a SOAP compiler framework, but if your needs are simple, string manipulation tends to avoid a lot of overhead and complexity...