AXL CUCM 7.X C# VS2008 Phone Query

Version 1
    This document was generated from CDN thread

    Created by: Alex Hannah on 13-05-2009 03:25:51 AM
    Team,
     
    I have successfully connected to AXL using Visual Studio 2k8 and the WSDL.  I am able to retrieve basic info like the CM OS Version and CUCM Application version.  I have stubbed out a method to retrieve information about a phone ( IE, phone load name, device calling search space, etc ).  How can I query the AXL interface for a specific phone, I don't see that in the method.  See the code snippet below:
     
    public string retrievePhoneIPAddress(AXLAPIService connectionObj)
            {
                GetPhoneReq phoneRequest = new GetPhoneReq();
                //How do I query for a specific phone by name ( ie PhoneRequest.filter = "SEPXXXXXXXXXXX"?????)
                GetPhoneRes phoneResponse = connectionObj.getPhone(phoneRequest);
                GetPhoneResReturn phoneResponseReturn = phoneResponse.@return;
                String deviceName = phoneResponseReturn.device.name.ToString();
                String deviceLoadName = phoneResponseReturn.device.phoneLoadName.ToString();
              
                return deviceName + " " + deviceLoadName;
            }
     
    I hope that makes sense.... Thanks!
     
    Alex

    Subject: RE: AXL CUCM 7.X C# VS2008 Phone Query
    Replied by: Anitha V on 13-05-2009 04:56:07 AM
    Hi Alex,
     
    I understand that you want to query a particular phone. I think getPhone request will help you in getting the details about the phone.
    The sample getPhone request is as follows:-
     
    GetPhoneReq ureq = new GetPhoneReq();
                ureq.PhoneName = "SEPXXXXXXXXX";
                GetPhoneRes res = new GetPhoneRes();
                try
                {
                    res = axlApiService.getPhone(ureq);
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Exception Occured " + ex.ToString());
                }
     
    This will give you all the details about the phone. Also, You may need to write the piece of code to print the response.
     
    Hope this helps.
     
    Thanks and Regards,
    Anitha

    Subject: RE: AXL CUCM 7.X C# VS2008 Phone Query
    Replied by: Alex Hannah on 13-05-2009 04:44:13 PM
    Anitha,
     
    I am sending you the code that I wrote at your suggestion.   However, in Visual Studio when you generate the C# Classes from the WSDL there is no method called GetPhoneReq.PhoneName.  Do you have any other suggestions on how to accomplish this?
     
    public string retrievePhoneIPAddress(AXLAPIService connectionObj)
            {
                GetPhoneReq phoneRequest = new GetPhoneReq();
                //How do I query for a specific phone by name ( ie PhoneRequest.filter = "SEPXXXXXXXXXXX"?????)
                phoneRequest.PhoneName = "SEPXXXXXXXXXXXX";
                GetPhoneRes phoneResponse = connectionObj.getPhone(phoneRequest);
                GetPhoneResReturn phoneResponseReturn = phoneResponse.@return;
                String deviceName = phoneResponseReturn.device.name.ToString();
                String deviceLoadName = phoneResponseReturn.device.phoneLoadName.ToString();
              
                return deviceName + " " + deviceLoadName;
            }
     
    The error message I receive in Visual Studio 2k8 is as follows: 
    Error      2              'GetPhoneReq' does not contain a definition for 'Phone' and no extension method 'Phone' accepting a first argument of type 'GetPhoneReq' could be found (are you missing a using directive or an assembly reference?)                C:\Documents and Settings\Student\My Documents\Visual Studio 2008\Projects\TBL-AXL\TBL-AXL\TBL AXL Interfaces\TBL_Phone_Query.cs              27           26           TBL-AXL

    Subject: RE: AXL CUCM 7.X C# VS2008 Phone Query
    Replied by: Walid Azab on 29-05-2009 03:13:34 PM
    Hi,
     
    Use the itemelementname property to select between phone id or phone name. Then use the item property to set the desired value.
     
     
    {
        GetPhoneReq req = new GetPhoneReq();
        
        req.ItemElementName = ItemChoiceType29.phoneName;
        req.Item = "SEP0019D2C92685";
        
        GetPhoneRes res = new GetPhoneRes();
        
        try {
            GetPhoneResReturn Phone = oAXL.getPhone(req).@return;
            Console.WriteLine(Phone.device.description);
        }
        catch (Exception ex) {
            Statustext.Text = ex.Message;
        }
    }