cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
926
Views
0
Helpful
1
Replies

c# Add user device Profile.

jmn
Level 1
Level 1


Hi All,

I'm a newbe with programing in c# AXL.

I have the following problem.

When I try to a AXL command I get a 500 error.

I'm running CUCM 8.6

This is my code:

        private void ADDDeviceProfile()
       
        {

            //string version = Properties.Settings.Default.CUCMVersion;
            string version = "8.5";

            string soap = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:ns=\"http://www.cisco.com/AXL/API/8.5\">\n";
            soap += "<soapenv:Header/>\n";
            soap += "<soapenv:Body>\n";
            soap += "<ns:adddeviceProfile sequence=\"1\">\n";
            soap += "<devicePofile>\n";
            soap += "<product>Cisco 7961G-GE</product>\n";
            soap += "<model>CCisco 7961G-GE/model>\n";
            soap += "<protocol>SCCP</protocol>\n";
            soap += "<class>Device Profile</class>\n";
            soap += "<name>jantest</name>\n";
            soap += "<description>Jan Meeling</description>\n";
            soap += "<protocolSide>User</protocolSide>\n";
            soap += "<lines>\n";
            soap += "<line index='1'>\n";
            soap += "<label>Jan Meeling Test-1234</label>\n";
            soap += "<display>Jan Meeling</display>\n";
            soap += "<dirn>\n";
            soap += "<pattern>123456789</pattern>\n";
            soap += "<usage>Device</usage>\n";
            soap += "<routePartitionName>DN_Global</routePartitionName>\n";
            soap += "</dirn>\n";
            soap += "<ringSetting>Use System Default</ringSetting>\n";
            soap += "<maxNumCalls>4</maxNumCalls>\n";
            soap += "<busyTrigger>2</busyTrigger>\n";
            soap += "</line>\n";
            soap += "</lines>\n";
            soap += "<services>\n";
            soap += "<service>\n";
            soap += "<telecasterServiceName>Mobility</telecasterServiceName>\n";
            soap += "<name>Mobility</name>\n";
            soap += "<url>http://XXX.XXX.XXX.10/emapp/EMAppServlet?device=#DEVICENAME#</url>\n";
            soap += "</service>\n";
            soap += "</services>\n";
            soap += "<softkeyTemplateName>" & strSoftKeyTempName & "</softkeyTemplateName>\n";
            soap += "</deviceProfileProfile>\n";
            soap += "<enableExtensionMobility>true</enableExtensionMobility>\n";
            soap += "</ns:adddeviceProfile>\n";
            soap += "</soapenv:Body>\n";
            soap += "</soapenv:Envelope>\n";

            Logging.Text += "---------|AXL Request|---------\n\n";
            Logging.Text += soap + "\n\n";


            #region AXL SOAP
            try
            {
                byte[] soapBytes = Encoding.UTF8.GetBytes(soap);

                ServicePointManager.ServerCertificateValidationCallback += delegate { return true; };
                HttpWebRequest httpRQ = (HttpWebRequest)HttpWebRequest.Create(string.Format(@"https://XXX.XXX.XXX.XXX:8443/axl/"));

                httpRQ.ProtocolVersion = System.Net.HttpVersion.Version10;
                httpRQ.Credentials = new NetworkCredential("AXLAdmin", "AXLPassowd");//Callmanager gebruikersnaam / password
                httpRQ.Method = "POST";
                httpRQ.ContentType = "text/xml; charset=utf-8";
                httpRQ.Accept = "text/xml";
                httpRQ.Headers.Add("SOAPAction: 'CUCM:DB ver=" + version + "'");
                httpRQ.ContentLength = soapBytes.Length;

                //Send the xml soap to cucm
                Stream stm = httpRQ.GetRequestStream();
                stm.Write(soapBytes, 0, soapBytes.Length);
                stm.Close();

                //Build the xml response
                XDocument responcedoc = new XDocument();
                HttpWebResponse responce = httpRQ.GetResponse() as HttpWebResponse;
                Stream responcedata = responce.GetResponseStream();
                StreamReader responsereader = new StreamReader(responcedata);
                Logging.Text += "\n---------|AXL Response|---------\n\n";
                XDocument respdoc = XDocument.Load(responsereader);
                Logging.Text += respdoc + "\n";
                soap = null;


            }
            catch (Exception ex)
            {
                Logging.Text += "\n";
                Logging.Text += "\n---------|AXL Error|---------\n\n";
                Logging.Text += string.Format("\n" + DateTime.Now + ":: ERROR :: Message: {0}\n", ex.Message);
            }

            #endregion
        }

Can any one please help me or point me in the write direction.

Thanks.

Regards,

Jan Meeling

1 Reply 1

jmn
Level 1
Level 1

If have found the problem.

What i done is the following:

1e) xmlns:ns=\"http://www.cisco.com/AXL/API/8.5\">\n" changed API/8.5 to API/7.1

2e) httpRQ.Headers.Add("SOAPAction: 'CUCM:DB ver=" + version + "'"); to CUCM:DB ver=7.1

And it is working fine now

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: