AXL connection problem with C# (VS 2005)

Version 1
    This document was generated from CDN thread

    Created by: SENOL KARAHASAN on 01-09-2008 08:39:25 AM
    Hi everyone,

    I am new at AXL api. I have a problem to connect CM. I am using Visual studio 2005 and C#. Our server is 6.01. I add AXLAPI.wsd as web referance. After that I make prober change which is writen in readme file at schema directory:
    1-
    public class BruteForcePolicy : System.Net.ICertificatePolicy
    {
    public bool CheckValidationResult(System.Net.ServicePoint sp, System.Security.Cryptography.X509Certificates.X509Certificate cert,
    System.Net.WebRequest request, int problem)
    {
    return true;
    }
    }
    2-
    public AXLAPIService(string ccmIp, string user, string password)
    {
    System.Net.ServicePointManager.CertificatePolicy = new BruteForcePolicy();

    this.Url = "https://" + ccmIp + ":8443/axl/";
    this.Credentials = new System.Net.NetworkCredential(user, password);
    }
    3-
    protected override System.Net.WebRequest GetWebRequest(Uri uri)
    {
    System.Net.HttpWebRequest request =(System.Net.HttpWebRequest)base.GetWebRequest(uri);
    if (this.PreAuthenticate)
    {
    System.Net.NetworkCredential nc = this.Credentials.GetCredential(uri,"Basic");
    if (nc != null)
    {
    byte[] credBuf = new System.Text.UTF8Encoding().GetBytes(nc.UserName + ":" + nc.Password);
    request.Headers = "Basic " + Convert.ToBase64String(credBuf);
    }
    }
    return request;
    }
    4-
    Class XUserUserGroup has a field which was generated incorrectly. One must remove one of the ‘[]’ from the two ‘[]http://developer.cisco.com/forums/][’ brackets after XUserUserGroupUserRolesUserRole field:

    public XUserUserGroupUserRolesUserRole[] userRoles;

    -> and example code is

    private void button1_Click(object sender, EventArgs e)
    {
    string sUserID = txtUserID.Text.Trim().ToString();
    sUserID = "IPTxxxxx";
    string sPassword = txtPassword.Text.Trim().ToString();
    sPassword = "xxxxxxxx";
    string ccmServer = txtServer.Text.Trim().ToString();
    ccmServer = "10.0.0.1";

    AXLAPIService oAXL = new AXLAPIService(ccmServer, sUserID, sPassword);
    • //*this function does not connect, I all oAXL function returns null

    ListDeviceByNameAndClassReq phoneByName = new ListDeviceByNameAndClassReq();

    phoneByName.searchString = "SEP%";
    ListDeviceResDevice[] phones = oAXL.listDeviceByNameAndClass(phoneByName).@return;

    foreach (ListDeviceResDevice phone in phones)
    {

    lstResult.Items.Add(phone.uuid);
    lstResult.Items.Add(phone.name);
    }
    }

    when I use this code, AXLAPIService oAXL function all returns null, I cannot connect call manager. I control user permission,

    https://10.0.0.1:8443/axl/ returns correct message:
    The AXL Web Service is working and accepting requests.
    Use HTTP POST to send a request.

    Please, someone help me about connecting to CM with using axl api using VS 2005 C#.

    Regards,
    Bilgehan.

    Edited by: SENOL KARAHASAN on 01.Eyl.2008 04:39

    Edited by: SENOL KARAHASAN on 01.Eyl.2008 04:45

    Subject: Re: AXL connection problem with C# (VS 2005)
    Replied by: Stefania Oliviero on 12-09-2008 09:03:50 AM
    I have teh same problem, but with version Cm 5.1. Any ideas ?

    Subject: Re: AXL connection problem with C# (VS 2005)
    Replied by: Stefania Oliviero on 12-09-2008 09:52:29 AM
    Solved.
    I found the solution in the following note in the reame.txt file:

    NOTE: By default, the AXLAPI.wsdl has the namespace http://www.cisco.com/AXL/API/1.0. The client stubs generated will also have this namespace.
    But the namespace returned in AXL response will depend on the Service Parameter "Send Valid Namespace in AXL Response" setting from CCMAdmin Service Parameter page.

    If it is set to "True", the AXL response will have namespace http://www.cisco.com/AXL/API/1.0 which will be in sync with the AXLAPI.wsdl namespace.
    But if this service parameter is set to "False", the namespace returned in AXL response will be http://www.cisco.com/AXL/1.0 which will not match with the namespace from the AXLAPI.wsdl.

    In such case, the application developer will be required to change the namespace in AXLAPI.wsdl to http://www.cisco.com/AXL/1.0 before creating the client stubs.
    This change is essential for the AXLAPI.wsdl to work correctly when service parameter "Send Valid Namespace in AXL Response" from CCMAdmin Service Parameter is set to "False".

    I changed the namespace to http://www.cisco.com/AXL/1.0, and then my code now it works...

    Edited by: Stefania Oliviero on 13-set-2008 9.55

    Subject: Re: AXL connection problem with C# (VS 2005)
    Replied by: Jan Aarts on 04-11-2008 03:57:26 PM
    Stefania, can you let me know how to update the namespace in the WSDL file?
    I've tried a couple of things but did not succeed.

    Subject: Re: AXL connection problem with C# (VS 2005)
    Replied by: Stefania Oliviero on 05-11-2008 09:25:58 AM
    I haven't modified the wsdl file. I created a new class AXLAPIService10, and then I replaced the old namespace http://www.cisco.com/AXL/API/1.0 with the new namespace http://www.cisco.com/AXL/1.0 (for the CCM 5.x).
    Then I created a superclass that manages the derived classes, via a config parameter.
    Example:
    return: System.Xml.Serialization.XmlElementAttribute("addAARGroupResponse", Namespace = "http://www.cisco.com/AXL/1.0")

    Subject: RE: Re: AXL connection problem with C# (VS 2005)
    Replied by: Ananthakumar k on 03-11-2009 06:07:32 AM
    Hi Stefania,
    I am getting similar error with call manager 7.1
    Can you suggest what to do ....
    Ananth

    Subject: RE: Re: AXL connection problem with C# (VS 2005)
    Replied by: Ananthakumar k on 06-11-2009 05:32:40 AM
    Hi, I could make this work without using cisco WSDL . Format the SOAP message properly and send the request to AXL web service. It works