Sample doAuthenticateUser request for CUCM 8.5

Version 1
    This document was generated from CDN thread

    Created by: Richard Blewett on 20-01-2012 05:39:50 AM
    The proxy generators for both WCF and ASMX generate code that blows up in the XmlSerializer. I currently only need to invoke one operation: doAuthenticateUser. Can someone post an example doAuthenticateUser request message so I can see what I need to do to build the request correctly?

    Subject: RE: Sample doAuthenticateUser request for CUCM 8.5
    Replied by: David Staudt on 20-01-2012 06:32:06 PM
    Here is an example that works on my 8.5(1) system:
     
    POST https://10.88.131.141:8443/axl/ HTTP/1.1
    Accept-Encoding: gzip,deflate
    Content-Type: text/xml;charset=UTF-8
    SOAPAction: "CUCMB ver=8.5 doAuthenticateUser"
    User-Agent: Jakarta Commons-HttpClient/3.1
    Content-Length: 444
    Authorization: Basic QWRtaW5pc3RyYXRvcjpjaXNjbyExMjM=
    Host: 10.88.131.141:8443
     
    <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:doAuthenticateUser sequence="1">
             <userid>cupuser1</userid>
             <!--You have a CHOICE of the next 2 items at this level-->
             <password>password</password>
    <!--         <pin>?</pin> -->
          </ns:doAuthenticateUser>
       </soapenv:Body>
    </soapenv:Envelope>
     
    ------------------------------
     
    HTTP/1.1 200 OK
    Set-Cookie: JSESSIONIDSSO=583F6C1C226B2F4A601CA578577404B5; Path=/; Secure
    Set-Cookie: JSESSIONID=F4A215575091DB7A443F6179168AC897; Path=/axl; Secure
    Content-Type: text/xml;charset=UTF-8
    Content-Length: 373
    Date: Fri, 20 Jan 2012 23:30:03 GMT
    Server: 
     
    <?xml version='1.0' encoding='UTF-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><ns:doAuthenticateUserResponse xmlns:ns="http://www.cisco.com/AXL/API/8.5"><return><userAuthenticated>true</userAuthenticated><code>0</code><daysToExpiry>0</daysToExpiry></return></ns:doAuthenticateUserResponse></soapenv:Body></soapenv:Envelope>

    Subject: RE: Sample doAuthenticateUser request for CUCM 8.5
    Replied by: Richard Blewett on 21-01-2012 02:14:24 AM
    Thanks alot David

    Subject: AXL REQUEST ERROR IN C#.NET
    Replied by: Shahid Haider on 23-01-2012 06:54:58 AM
    I am trying to send axl request to CALL MANAGER 8.0 ( CUCM 8.0) , Unable to get the phone info, I am using visual studio 2008 with c#.net, .net framework 3.5

     


    using System;
    using System.Collections;
    using System.ComponentModel;
    using System.Data;
    using System.Linq;
    using System.Web;
    using System.Web.Services;
    using System.Web.Services.Protocols;
    using System.Xml.Linq;
    using System.Xml.Serialization;
    using System.Net;
    using System.IO;
    using System.Text;
    using System.Net.Security;
    using System.Security.Cryptography.X509Certificates;


    using System.Diagnostics;

    namespace phone_lock_xml_service
    {
        /// <summary>
        /// Summary description for Service1
        /// </summary>
        [WebService(Namespace = "http://tempuri.org/")]
        [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
        [ToolboxItem(false)]
        // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
        // [System.Web.Script.Services.ScriptService]
        public class Service1 : System.Web.Services.WebService
        {

           
          


    public string send_request()
            {

                string strAuthentication = string.Empty;
                string strUriHttps = @"https://192.168.15.102:8443/axl/";
                string rep = string.Empty;

                try
                {
                 
                  

                    ServicePointManager.ServerCertificateValidationCallback += delegate { return true; };
                    HttpWebRequest oWRequest = (HttpWebRequest)HttpWebRequest.Create(new Uri(strUriHttps));
                    oWRequest.ProtocolVersion = System.Net.HttpVersion.Version10;
                    oWRequest.Credentials = new NetworkCredential("admin", "ccievoice");
               
                    oWRequest.Timeout = 100000;
                    oWRequest.Method = "POST";
                    oWRequest.ContentType = "text/xml";
                    strAuthentication = "admin" + ":" + "ccievoice";
                    strAuthentication = Convert.ToBase64String(Encoding.ASCII.GetBytes(strAuthentication));

                    String Auth = "admin" + ":" + "ccievoice";

                    Auth = Convert.ToBase64String(Encoding.ASCII.GetBytes(Auth));
              
                            String sAXLSOAPRequest = null;        // will hold the complete request,

                                                  // HTTP header and SOAP payload


            String sAXLRequest = null;            // will hold only the SOAP payload

          
            byte[] bArray = null;                 // buffer for reading response from server

          


            // Build the HTTP Header

            sAXLSOAPRequest = "POST /axl/ HTTP/1.0\r\n";

            sAXLSOAPRequest += "Host: 192.168.15.102:8443\r\n";

            sAXLSOAPRequest += "Authorization: Basic "+strAuthentication+"==\r\n";

            sAXLSOAPRequest += "Accept: text/*\r\n";
         

            sAXLSOAPRequest += "Content-type: text/xml\r\n";
           sAXLSOAPRequest += "SOAPAction: \"CUCMB ver=8.0\"\r\n";
            sAXLSOAPRequest += "Content-length: ";

            // Build the SOAP payload

            sAXLRequest = "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" ";

            sAXLRequest += "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"> ";

            sAXLRequest += "<SOAP-ENV:Body> <axl:getPhone xmlns:axl=\"http://www.cisco.com/AXL/1.0\" ";

            sAXLRequest += " xsi:schemaLocation=\"http://www.cisco.com/AXL/1.0 http://gkar.cisco.com/schema/axlsoap.xsd\" ";

            sAXLRequest += "sequence=\"1234\"> <phoneName>SEP0013195155EC</phoneName> ";

            sAXLRequest += "</axl:getPhone> </SOAP-ENV:Body> </SOAP-ENV:Envelope>";

            // finish the HTTP Header




            sAXLSOAPRequest += sAXLRequest.Length.ToString();

            sAXLSOAPRequest += "\r\n\r\n";

            // now add the SOAP payload to the HTTP header, which completes the AXL SOAP request
            sAXLSOAPRequest += sAXLRequest;

                    Stream stream = oWRequest.GetRequestStream();

                    stream.Write(System.Text.Encoding.ASCII.GetBytes(sAXLSOAPRequest), 0,sAXLSOAPRequest.Length);
                    stream.Close();

                    HttpWebResponse oWResponse = (HttpWebResponse)oWRequest.GetResponse();

                    Stream recStream = oWResponse.GetResponseStream();
                    StreamReader readStream = new StreamReader(recStream, Encoding.UTF8);
                    rep = readStream.ReadToEnd();
                }
                catch (Exception ex)
                {

                    lblMessage.Text = ex.Message.ToString();
                }

                return rep;


            }


    Error after sending the request as follows:


    <?xml version="1.0" encoding="utf-8" ?>
      <string xmlns="http://tempuri.org/"><SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Header/><SOAP-ENV:Body><SOAP-ENV:Fault><faultcode>SOAP-ENV:Client</faultcode><faultstring>Content is not allowed in prolog.</faultstring><detail><axl:Error xmlns:axl="http://www.cisco.com/AXL/API/1.0"><axl:code>5001</axl:code><axl:message>Content is not allowed in prolog.</axl:message></axl:Error></detail></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope></string>


    Any suggestion regarding this error will be appreciated.

    Subject: RE: AXL REQUEST ERROR IN C#.NET
    Replied by: David Staudt on 23-01-2012 01:29:58 PM
    Apologies, I included the full raw request including the HTTP header (starts with 'POST') for illustrative purposes, but in your usage that block will be provided automatically by the HttpWebRequest method (note you may need to tweak the object's properties to produce header data to match.)  If you start the requst with the <SOAP-ENV:envelope> line, you'll get closer.

    Subject: RE: AXL REQUEST ERROR IN C#.NET
    Replied by: Breno Lucena on 24-01-2012 09:10:42 AM
    Shahid,

    Step 1)  create a new Default.aspx (instead of, Default.asmx)

    Step 2) Clean the Default.aspx, to look like this:

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="MyNameSpace.Default" %>

    Step 3) Implement your code on the code behind Default.aspx.cs

     1using System;
     2using System.Collections.Generic;
     3using System.Linq;
     4using System.Web;
     5using System.Web.UI;
     6using System.Web.UI.WebControls;
     7using Wittel.Phone.Locker.Service.Properties;
     8using System.Net;
     9using System.Text;
    10using System.IO;
    11
    12namespace Wittel.Phone.Locker.Service
    13{
    14    public partial class DoLock : System.Web.UI.Page
    15    {
    16        public string ServiceUrl
    17        {
    18            get
    19            {
    20                string tempUrl = string.Empty;
    21
    22                if (Settings.Default.ccmIsSecure)
    23                {
    24                    tempUrl = string.Format("https://{0}:{1}/axl/", Settings.Default.ccmIp, Settings.Default.ccmSecurePort);
    25                }
    26                else
    27                {
    28                    tempUrl = string.Format("http://{0}:{1}/axl/", Settings.Default.ccmIp, Settings.Default.ccmPort);
    29                }
    30
    31                return tempUrl;
    32            }
    33            private set { }
    34        }
    35
    36        protected void Page_Load(object sender, EventArgs e)
    37        {
    38            try
    39            {
    40                if (!IsPostBack)
    41                {
    42
    43                    ServicePointManager.ServerCertificateValidationCallback += delegate { return true; };
    44                    HttpWebRequest request = (HttpWebRequest)WebRequest.Create(new Uri(this.ServiceUrl));
    45                    request.ProtocolVersion = System.Net.HttpVersion.Version10;
    46                    request.Credentials = new NetworkCredential(Settings.Default.appUser, Settings.Default.appPwd);
    47                    request.Timeout = 100000;
    48                    request.Method = "POST";
    49                    request.ContentType = "text/xml";
    50
    51                    String axlSoapRequest = null;
    52                    String axlRequestEnvelope = null;
    53
    54                    axlSoapRequest = "POST /axl/ HTTP/1.0\r\n";
    55                    axlSoapRequest += "Host: " + Settings.Default.ccmIp + ":" + (Settings.Default.ccmIsSecure ? Settings.Default.ccmSecurePort : Settings.Default.ccmPort) + "\r\n";
    56                    axlSoapRequest += "Authorization: Basic " + Convert.ToBase64String(Encoding.ASCII.GetBytes((Settings.Default.appUser + ":" + Settings.Default.appPwd))) + "==\r\n";
    57                    axlSoapRequest += "Accept: text/*\r\n";
    58                    axlSoapRequest += "Content-type: text/xml\r\n";
    59                    axlSoapRequest += "SOAPAction: \"CUCM:DB ver=8.0\"\r\n";
    60                    axlSoapRequest += "Content-length: ";
    61
    62                    axlRequestEnvelope = "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"> ";
    63                    axlRequestEnvelope += "<SOAP-ENV:Body> ";
    64                    axlRequestEnvelope += "<axl:getPhone xmlns:axl=\"http://www.cisco.com/AXL/1.0\" xsi:schemaLocation=\"http://www.cisco.com/AXL/1.0 http://gkar.cisco.com/schema/axlsoap.xsd\" sequence=\"123456\"> ";
    65                    axlRequestEnvelope += "<phoneName>SEP...</phoneName> ";
    66                    axlRequestEnvelope += "</axl:getPhone> ";
    67                    axlRequestEnvelope += "</SOAP-ENV:Body> ";
    68                    axlRequestEnvelope += "</SOAP-ENV:Envelope>";
    69
    70                    axlSoapRequest += axlRequestEnvelope.Length.ToString();
    71                    axlSoapRequest += "\r\n\r\n";
    72
    73                    Stream requestStream = request.GetRequestStream();
    74
    75                    requestStream.Write(System.Text.Encoding.ASCII.GetBytes(axlSoapRequest), 0, axlSoapRequest.Length);
    76                    requestStream.Close();
    77
    78                    HttpWebResponse response = (HttpWebResponse)request.GetResponse();
    79
    80                    Stream responseStream = response.GetResponseStream();
    81                    StreamReader readStream = new StreamReader(responseStream, Encoding.UTF8);
    82
    83                    Response.ContentType = "text/xml";
    84                    Response.Charset = "utf-8";
    85
    86                    Response.Write(readStream.ReadToEnd());
    87                }
    88            }
    89            catch (Exception ex)
    90            {
    91                throw ex;
    92            }
    93        }
    94    }
    95}


    Step 4) It will response you the code below:

    1
    2<?xml version="1.0"?>
    3-<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Header/>-<SOAP-ENV:Body>-<SOAP-ENV:Fault><faultcode>SOAP-ENV:Client</faultcode><faultstring>Content is not allowed in prolog.</faultstring>-<detail>-<axl:Error xmlns:axl="http://www.cisco.com/AXL/API/1.0"><axl:code>5001</axl:code><axl:message>Content is not allowed in prolog.</axl:message><request/></axl:Error></detail></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope>


    I believe it will solve your response problem!

    PS: David, would you mind to help us with the response failure described on the 4th step?

    Subject: RE: AXL REQUEST ERROR IN C#.NET
    Replied by: Shahid Haider on 25-01-2012 01:40:29 AM
    Finally, I got it right
     
    using System;
    using System.Collections;
    using System.ComponentModel;
    using System.Data;
    using System.Linq;
    using System.Web;
    using System.Web.Services;
    using System.Web.Services.Protocols;
    using System.Xml.Linq;
    using System.Xml.Serialization;
    using System.Net;
    using System.IO;
    using System.Text;
    using System.Xml;
    using System.Net.Security;
    using System.Security.Cryptography.X509Certificates;
    using System.Diagnostics;

    namespace phone_lock_xml_service
    {
        /// <summary>
        /// Summary description for Service1
        /// </summary>
          [WebService(Namespace = "http://tempuri.org/")]
        [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
        [ToolboxItem(false)]
        // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
        // [System.Web.Script.Services.ScriptService]
        public class Service1 : System.Web.Services.WebService
        {

           

     
     
     
     public string send_request()
            {

                  try
                {
                    FileStream fileStream = System.IO.File.OpenRead(@"C:\soap_envelope.xml");
                    byte[] byData2 = new byte[fileStream.Length];
                    fileStream.Read(byData2, 0, byData2.Length);
                  
                    ServicePointManager.ServerCertificateValidationCallback += delegate { return true; };
                    HttpWebRequest oWRequest = (HttpWebRequest)HttpWebRequest.Create(@"https://192.168.15.102:8443/axl/");
                  
                    oWRequest.ProtocolVersion = System.Net.HttpVersion.Version10;
                    oWRequest.Credentials = new NetworkCredential("admin", "ccievoice");// call manager admin user, password
                    oWRequest.Method = "POST";
                    oWRequest.ContentType = "text/xml; charset=utf-8";
                    oWRequest.Accept = "text/xml";
                    oWRequest.ContentLength = byData2.Length;
                    Stream stm =oWRequest.GetRequestStream(); 
                    stm.Write(byData2,0,byData2.Length);
                    stm.Close();

                    // build response object
                    HttpWebResponse response = oWRequest.GetResponse() as HttpWebResponse;
                    Stream responsedata = response.GetResponseStream();
                    StreamReader responsereader = new StreamReader(responsedata);
                    return responsereader.ReadToEnd();
                   
                }
     
    xml file soap_envelope.xml look like this
     
    <?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <SOAP-ENV:Body> <axl:getPhone xmlns:axl="http://www.cisco.com/AXL/8.0" xsi:schemaLocation="http://www.cisco.com/AXL/8.0 http://gkar.cisco.com/schema/axlsoap.xsd" sequence="1234"> <phoneName>SEP00</phoneName> </axl:getPhone> </SOAP-ENV:Body> </SOAP-ENV:Envelope>
     
    kindly note that i am using CUCM 8.0 (Callmanager 8.0 version) that is why i think you put http://www.cisco.com/AXL/8.0