How to list all lines in the device using GetPhone in C#?

Version 1
    This document was generated from CDN thread

    Created by: sujit pillai on 04-06-2009 12:21:25 PM
    I am using C#. I had tried GetPhoneReq and GetPhoneRes, in response of GetPhoneRes i got getphres.@return.device.lines.Items how can i get the line in the lines instead of Items, and all line information like Directory Number, calling serarch space, alerting name and display of the perticular line in device? is it possible to modify all these information using UpdatePhone?
     
    Thanks in advance
     
     
     
     
     

     
     
     

    Subject: RE: How to list all lines in the device using GetPhone in C#?
    Replied by: David Staudt on 04-06-2009 04:27:12 PM
    getPhone will return a list of line elements with information on the 'line appearance'.  To get the full details of the actual line, you will need to take the <lines><dirn uuid=""> attribute and use it with the getLine request:
     
    getPhone snippet
     
                   <lines>
                      <line index="1" uuid="{FBC43AEE-F404-AA78-5C12-DC81A696083E}">
                         <label/>
                         <asciiLabel/>
                         <display/>
                         <dirn uuid="{6D057752-9267-7F4D-7F96-D6677D528710}"/>
     
    getLine request
     
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="http://www.cisco.com/AXL/API/7.0">
       <soapenv:Header/>
       <soapenv:Body>
          <ns:getLine sequence="1">
             <uuid>{6D057752-9267-7F4D-7F96-D6677D528710}</uuid>
          </ns:getLine>
       </soapenv:Body>
    </soapenv:Envelope>

    Subject: RE: How to list all lines in the device using GetPhone in C#?
    Replied by: sujit pillai on 08-06-2009 11:26:35 AM
    Hi David,
     
    Thanks for your reply.
     
    i am using C#, i create a object of GetPhoneRes and returning the values but in lines i dont find any line parameter. I got Items only one parameter in lines so i can not retrive line information.

    getphres.@return.device.lines.Items

    how can i get line in lines?

    Thanks

    Subject: RE: How to list all lines in the device using GetPhone in C#?
    Replied by: Jonathan Withers on 08-06-2009 12:47:00 PM
    You should be able to get your line information using the following c#:-
     
                    GetPhoneReq req = new GetPhoneReq();
                    req.ItemElementName = ItemChoiceType8.phoneName;
                    req.Item = "DEVICENAME";

                    GetPhoneRes resp = api.getPhone(req);

                    foreach (XLine line in resp.@return.device.lines.Items)
                    {
                        Console.WriteLine(line.ToString());
                    }
     
     
     

    Subject: RE: How to list all lines in the device using GetPhone in C#?
    Replied by: sujit pillai on 10-06-2009 10:38:41 AM
    Thanks Jonathan for your kind reply. I able to get line information now, but by using uuid of the line i can not get line information in getlineres.
     
    i am using getline function for retriving line information for that i passed uuid of line to the getlinereq but it gives me null object.
     
    i tried
     
     
     
    <font size="2" color="#008080">
    GetLineReq
    </font>
    getlinereq = new GetLineReq();<font size="2">
     
    </font>
     

    getlinereq.sequence = 1;
    getlinereq.uuid = line.uuid; // line uuid from getphoneres

    <font size="2" color="#008080">
    GetLineRes
    </font>
    getlineres = aas.getLine(getlinereq);

     
    gives me Item not valid: The specified Line was not found

    Thanks in advance

    Subject: RE: How to list all lines in the device using GetPhone in C#?
    Replied by: Jonathan Withers on 11-06-2009 07:11:05 AM
    If you would like to post me some code i'm happy to take a look.

    Subject: RE: How to list all lines in the device using GetPhone in C#?
    Replied by: sujit pillai on 11-06-2009 11:12:55 AM
    Hi Jonathan,
     
    Now by using getphone function i got line information but that information is limited or not all fields from cisco CM is available to view like Directory Name(DN), Calling Search Space of Line, Alerting name of line. so i am trying GetLine and UpdateLine function
     
    GetLine function accept UUID of the line Which i got from GetPhone function (line UUID) , Even i passed UUID its gives me NULL object.
     
    I tried following
     
    GetLineReq getlinereq = new GetLineReq();
    getlinereq.sequence = 1;
    getlinereq.uuid = line.uuid;  // line uuid from getphoneres
     
    GetLineRes getlineres = axlc.getLine(getlinereq);

    This gives me,
    Item not valid: The specified Line was not found
    even the line is there and that line i can access from Cisco CM
     
    can u help me on this
     
    Thanks in advance
     
     
     
     

    Subject: RE: How to list all lines in the device using GetPhone in C#?
    Replied by: Jonathan Withers on 11-06-2009 11:30:09 AM
    Hi Sujit,
     
    I think that you are on the right lines with your approach. There's one line of code missing which tells the CUCM webservice which field you are searching on. (My code is based on CUCM 7, if you are using 6 then it will be a different ItemChoiceType  - check your proxy class for this)
     
     
    GetLineReq getlinereq = new GetLineReq();
    getlinereq.sequence = 1;
    getlinereq.uuid = line.uuid;  // line uuid from getphoneres
    getlinereq.ItemElementName = ItemChoiceType8.phoneId;


    GetLineRes getlineres = axlc.getLine(getlinereq);
     
    Jon

    Subject: RE: How to list all lines in the device using GetPhone in C#?
    Replied by: sujit pillai on 13-06-2009 10:13:28 AM
    Hi Jonathan,
     
    I am working on 6.1 version in this version uuid is ItemElementType13, bt when i give
     
    getlinereq.uuid = line.uuid;  // line uuid from getphoneres
    getlinereq.ItemElementName = ItemChoiceType8.uuid;

    it gives me error cannot implicitly convert ItemchoiceType13 to ItemChoiceType52
     
    I think uuid is direct field available not required getlinereq.ItemElementName = ItemChoiceType8.uuid;
    there are only follwing fields available
     
      <xsd:complexType name="GetLineReq">
        <xsd:complexContent>
          <xsd:extension base="axlapi:GetNumPlanPattern" />
        </xsd:complexContent>
      </xsd:complexType>
      <xsd:element name="getLine" type="axlapi:GetLineReq" />
      <xsd:complexType name="GetLineRes">
        <xsd:complexContent>
          <xsd:extension base="axlapi:APIResponse">
            <xsd:sequence>
              <xsd:element name="return">
                <xsd:complexType>
                  <xsd:sequence>
                    <xsd:element name="directoryNumber" type="axlapi:XNPDirectoryNumber" />
                  </xsd:sequence>
                </xsd:complexType>
              </xsd:element>
            </xsd:sequence>
          </xsd:extension>
        </xsd:complexContent>
      </xsd:complexType>
      <xsd:element name="getLineResponse" type="axlapi:GetLineRes" />
      <xsd:complexType name="GetNumPlanPattern" abstract="true">
        <xsd:complexContent>
          <xsd:extension base="axlapi:APIRequest">
            <xsd:sequence>
              <!--Choice Tag Skipped for .NET -->
              <xsd:element name="uuid" type="axlapi:XUUID" />
              <xsd:sequence>
                <xsd:element name="pattern" type="xsd:string" />
                <xsd:choice>
                  <xsd:element name="routePartitionId" type="axlapi:XUUID" />
                  <xsd:element name="routePartitionName" type="axlapi:String50" />
                </xsd:choice>
                <xsd:choice>
                  <xsd:element name="routeFilterId" type="axlapi:XUUID" />
                  <xsd:element name="routeFilterName" type="axlapi:String50" />
                </xsd:choice>
              </xsd:sequence>
              <!--Choice Tag Skipped for .NET -->
            </xsd:sequence>
          </xsd:extension>
        </xsd:complexContent>
      </xsd:complexType>

    Subject: RE: How to list all lines in the device using GetPhone in C#?
    Replied by: sujit pillai on 15-06-2009 01:08:14 PM
    Hi Jonathan,
     
    i unable to update display of line using UpdatePhone
    i tried follwing way
     
    UpdatePhoneReq uphreq = new UpdatePhoneReq();
    uphreq.Item = "SEP00EF001122";
     
    foreach(XLine line in uphreq.lines.Items)
    {
        line.display = "Test Name";
    }
    StandardResponse SR = axla.UpdatePhone(uphreq);
     
    // it gives me error
    also i can not get Directory no of line anywhere in line information
     
    Thanks
     
     

    Subject: RE: How to list all lines in the device using GetPhone in C#?
    Replied by: sujit pillai on 17-06-2009 02:00:49 PM
     
    Hi Jonathan,
     
    Can u help me on update display of line using UpdatePhone function.
     
    i tried
     
    GetPhoneReq gpreq = new GetPhoneReq();
    gpreq.Item = "Device name";
    gpreq.ItemElementName = ItemChoiceType.name;
    GetPhoneRes gpres = myaxl.GetPhone(gpreq);
     
    UpdatePhoneReq upreq = new UpdatePhoneReq();
    upreq.Item = "Device name";
    upreq.ItemElementName = ItemChoiceType.name;
     
    UpdatePhoneReqLines upreqline = new UpdatePhoneReqLines();
    //upreqline.Items = upreq.lines.Items;
    upreqline.Items = gpreq.@return.device.lines.Items;
     
    foreach (Xline line in upreqline.Items)
    {
    line.display = "disp name";
    }
     
    StandardResponse sR = aas.updatePhone(UphReq);

    This will not take effect.
    Is it i am on right track ?
    if not can u suggest me the right way to do.
     
    Thanks in advance