How to get IP address phone having the phone extension

Version 1
    This document was generated from CDN thread

    Created by: Marcelo Rocha on 09-08-2008 09:16:32 PM
    Hi:
    I posted the same question in the IP Services foro, but I think this foro is more appropiate.

    I've got the phone extension number from the Active Directory using LDAP, then, I need the IP phone address to make a PUSH data to that phone.

    How can I do this in a simple way?

    thank you in advance,
    marcelo

    Subject: Re: How to get IP address phone having the phone extension
    Replied by: Madhukar Bhandaryr on 16-09-2008 05:53:38 AM
    You could send a SOAP request to the machine to fetch the info about IP phones(including IP address) and LIne number using the name of the device:
    <?xml version="1.0" encoding="utf-8"?>
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <soapenv:Body>
    <ns1:SelectCmDevice soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="http://schemas.cisco.com/ast/soap/">
    <StateInfo xsi:type="xsd:string"/>
    <CmSelectionCriteria href="#id0"/>
    </ns1:SelectCmDevice>
    <multiRef id="id0" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns2:CmSelectionCriteria" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns2="http://schemas.cisco.com/ast/soap/">
    <MaxReturnedDevices xsi:type="xsd:unsignedInt">200</MaxReturnedDevices>
    <Class xsi:type="xsd:string">Phone</Class>
    <Model xsi:type="xsd:unsignedInt">255</Model>
    <Status xsi:type="xsd:string">Registered</Status>
    <NodeName xsi:type="xsd:string" xsi:nil="true"/>
    <SelectBy xsi:type="xsd:string">Name</SelectBy>
    <SelectItems soapenc:arrayType="ns2:SelectItem[1]" xsi:type="soapenc:Array">
    <item href="#id1"/>
    </SelectItems>
    </multiRef>
    <multiRef id="id1" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns3:SelectItem" xmlns:ns3="http://schemas.cisco.com/ast/soap/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
    <Item xsi:type="xsd:string">*</Item></multiRef>
    </soapenv:Body>
    </soapenv:Envelope>

    Here i have used * to fetch the information of all the phones.

    You could mention the phone name say SEPxxxxxxxx to fetch the information on that phone.

    HTH

    Thanks and Regards,
    Madhukar

    Subject: RE: Re: How to get IP address phone having the phone extension
    Replied by: Nataraj Nayak on 23-02-2009 08:54:22 AM
    Hi
       I have the same question.  Can anyone provide a SQL query for translating the extension to IP address in Call manager version 5.x ?  We are using CCM 5.1.3.
    Thanks
    Nataraj
     

    Subject: RE: Re: How to get IP address phone having the phone extension
    Replied by: Stephan Steiner on 23-02-2009 04:21:37 PM
    The IP Address is not in any database.. hence there's no SQL statement to get that information. Instead you need to perform the AXL serviceability request that Madhukar gave you.

    Subject: RE: Re: How to get IP address phone having the phone extension
    Replied by: David Staudt on 23-02-2009 06:44:35 PM
    Starting with just the DN/line number, you will need two SOAP requests:
     
    - Admin AXL: use <executeSQLQuery to match DN with a Device Name.  See: http://developer.cisco.com/web/axl/forums/-/message_boards/message/1112859
     
    - Serviceability:RisPort AXL: as mentioned by Madhu previously, using  the Device Name and returning IP address

    Subject: RE: Re: How to get IP address phone having the phone extension
    Replied by: Alexandr Kulbida on 17-03-2009 01:36:56 PM
    You could send a SOAP request to the machine to fetch the info about IP phones(including IP address) and LIne number using the name of the device:
    ........
    Thanks and Regards,
    Madhukar

     
    Hello,Madhukar
    I'm novice in AXL.
    What I need to run this SOAP request to receive info from CUCM?

    Subject: RE: Re: How to get IP address phone having the phone extension
    Replied by: Nataraj Nayak on 18-03-2009 11:53:31 PM
    Hi David
     
        I am trying to execute the SOAP message given by Madhukar here using CURL (as seen from my other post at http://developer.cisco.com/web/axl/forums/-/message_boards/message/1125846).   But the call manager 5.x returns a 5003 error "No Handler found for SelectCmDevice" on this request - the same error whether I use * or a specific device name SEP###### as parameter:
     
    C:\>curl -k -u ipphoneadminaxl -H "Content-type: text/xml;" -d @listRequest.xml https://172.26.16.102:8443/axl/
    Enter host password for user 'ipphoneadminaxl':
    <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>No Handler found for SelectCmDevice</faultstring><detail><axl:Error xmlns:axl="http://www.cisco.com/AXL/1.0"><axl:code>5003</axl:code><axl:message>No Handler found for SelectCmDevice</axl:message><request>multiRef</request></axl:Error></detail></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP
    -ENV:Envelope>
     
          What am I doing wrong?  Is it a mismatch of CM version?  Please help.
     
    Thanks
    Nataraj

    Subject: RE: Re: How to get IP address phone having the phone extension
    Replied by: David Staudt on 19-03-2009 04:43:53 AM
    Make sure the target URL is for RisPort (which includes SelectCmDevice.)  It looks like you are using the Axl URL.  For RisPort:
     
    https://servername:8443/realtimeservice/services/RisPort

    Subject: RE: Re: How to get IP address phone having the phone extension
    Replied by: Nataraj Nayak on 24-03-2009 12:01:56 AM
    Hi David
     
          Thank you, I realized that just after I posted my previous question.   But I need your help further -  Now I am running into a wired issue.
     
          I am able to authenticate and get to the RisPort URL, from a browser.  Both https://172.26.16.100:8443/realtimeservice/services/RisPort and https://172.26.16.100:8443/realtimeservice/services/RisPort?wsdl are returning what they should.  
     
           But when I try the same using CURL, I have some issues.   I have the exact SOAP request as in Madhukar's post stored in my listRequest.xml file.
     
          First I tried without the SOAPAction header per your other post.  The result is,
     
    C:\Program Files\curl-7.19.3>curl -k -u ipphoneadminaxl -H "Content-type: text/xml;" -d @listRequest.xml https://172.26.16.100:8443/realtimeservice/services/RisPort
    Enter host password for user 'ipphoneadminaxl':
    <?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://
    www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
     <soapenv:Body>
      <soapenv:Fault>
       <faultcode xmlns:ns1="http://xml.apache.org/axis/">ns1:Client.NoSOAPAction</faultcode>
       <faultstring>no SOAPAction header!</faultstring>
       <detail>
        <ns2:hostname xmlns:ns2="http://xml.apache.org/axis/">SAGPHWVC02.SAGPH.ORG</ns2:hostname>
       </detail>
      </soapenv:Fault>
     </soapenv:Body>
    </soapenv:Envelope>
     
          Then I added the same SOAPAction header as what is suggested in the CURL wiki article (I was not sure what it should be) and now the result is "Unauthorized".
     
    C:\Program Files\curl-7.19.3>curl -k -u ipphoneadminaxl -H "Content-type: text/xml;" -H "SOAPAction: 'CUCMB ver=5.0'" -d @listRequest.xml https://172.26.16.100:8443/realtimeservice/services/RisPort
    Enter host password for user 'ipphoneadminaxl':
    <?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <soapenv:Body>
    <soapenv:Fault>
      <faultcode xmlns:ns1="http://xml.apache.org/axis/">ns1:Server.Unauthorized</faultcode>
      <faultstring>User 'ipphoneadminaxl' not authorized to 'realtimeservice'</faultstring>
      <detail><ns2:hostname xmlns:ns2="http://xml.apache.org/axis/">SAGPHWVC00.sagph.org</ns2:hostname></detail>
    </soapenv:Fault>
    </soapenv:Body>
    </soapenv:Envelope>
     
           Please help.  I really appreciate you resolving a number of issues in these forums - you have been very helpful to me too.
     
    Thanks
    Nataraj

    Subject: RE: Re: How to get IP address phone having the phone extension
    Replied by: David Staudt on 24-03-2009 12:47:13 AM
    - The SOAPHeader header _is_ required for RisPort.  Technically it's not necessary for Admin AXL, on versions that support the v6.0 schema - though as of UCM 8.0 the SOAPHeader will be required on all Admin AXL requests, too.  I updated the CURL how-to to be more friendly to linux/windows and it should now work on both.
     
    - Note, the content of the SOAPHeader is _different_ depending on which service you are using...looks like you are specifying the Admin AXL SOAPHeader.  For RisPort, you need to specify something like: SOAPAction: "http://schemas.cisco.com/ast/soap/action/#RisPort#SelectCmDevice"  Note that you may need to change #SelectCmDevice to reflect whatever request you are actually using.
     
    - Probably using the wrong SOAPHeader is causing an authentication failure.  However, if you haven't checked, make sure the user is configured in UCM Admin with 'Standard AXL API' role - i.e. belonging to 'Standard CCM Super Users' group or another group with 'Standard AXL API' role.

    Subject: RE: Re: How to get IP address phone having the phone extension
    Replied by: Nataraj Nayak on 24-03-2009 11:01:04 PM
    Hi David
     
          Yes, it started working after we followed both of your suggestions. 
     
           For the benefit of everyone else who is looking for the same info, I am listing the two-step process here.  This works for me using the CURL method (http://developer.cisco.com/web/axl/wikidocs?src=/wiki/display/AXL/how-to_CURL).  In this example, I want to find out the all the IP's associated with the extension number 2586.
     
    1. To obtain the 'phone extension' to 'device name' relationship, store the following XML in a file (I named it 'nameRequest.xml')
     
    <?xml version="1.0" encoding="UTF-8"?>
    <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
      <SOAP-ENV:Body>
        <axlapi:executeSQLQuery xmlns:axlapi="http://www.cisco.com/AXL/API/1.0" xmlns:axl="http://www.cisco.com/AXL/API/1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" sequence="1" xsi:schemaLocation="http://www.cisco.com/AXL/API/1.0 axlsoap.xsd">
          <sql>select name, dnorpattern from device, numplan, devicenumplanmap where device.pkid=devicenumplanmap.fkdevice and numplan.pkid=devicenumplanmap.fknumplan and dnorpattern='2586'</sql>
        </axlapi:executeSQLQuery>
      </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>
     
          Then invoke the CURL command:
     
    curl -k -u <adminUser> -H "Content-type: text/xml;" -d @nameRequest.xml https://<CMServer>:8443/axl/
     
          which returns all the device names associated with that extension, as seen below:
     
    <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>
    <axl:executeSQLQueryResponse sequence="1" xmlns:axl="http://www.cisco.com/AXL/1.0" xmlns:xsi="http://www.cisco.com/AXL/1.0">
    <return>
      <row><name>SEP002290038EE5</name><dnorpattern>2586</dnorpattern></row>
      <row><name>SEP001560CC55A4</name><dnorpattern>2586</dnorpattern></row>
      <row><name>SEP001302AF8069</name><dnorpattern>2586</dnorpattern></row>
    </return>
    </axl:executeSQLQueryResponse>
    </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>
     
    2.  Now take the query as given by Madhukar's post above, replace * with a specific device name returned in step 1, and store it in another file (I named it ipRequest.xml)
     
         Invoke the curl command:
     
    curl -k -u <adminUser> -H "Content-type: text/xml;" -H "SOAPAction: 'http://schemas.cisco.com/ast/soap/action/#RisPort#SelectCmDevice'" -d @ipRequest.xml https://<CMServer>:8443/realtimeservice/services/RisPort
     
         I am not listing the complete reply because it is big, but I can see the following information in the body:
     
    <item xsi:type="ns1:CmDevice">
      <Name xsi:type="xsd:string">SEP002290038EE5</Name>
      <IpAddress xsi:type="xsd:string">172.26.29.228</IpAddress>
      <DirNumber xsi:type="xsd:string">2586-Registered</DirNumber>
     
          Thanks a zillion to David again, for resolving all my issues.
     
    -Nataraj

    Subject: RE: Re: How to get IP address phone having the phone extension
    Replied by: Nataraj Nayak on 26-03-2009 08:43:02 PM
    Hi David
     
         I have one follow up question.  The serviceability call SelectCmDevice is returning me only 200 records.  Even after I changed the parameter in my request XML to
     
    <MaxReturnedDevices xsi:type="xsd:unsignedInt">500</MaxReturnedDevices>
     
       - it is still returning only 200 records.  Is there any parameter on the CUCM that can be changed to increase this limit?
     
    Thanks
    Nataraj
     

    Subject: RE: Re: How to get IP address phone having the phone extension
    Replied by: Stephan Steiner on 31-03-2009 06:41:07 AM
    No you cannot. You need to get all the devices you want to look up using AXL (executeSqlQuery), then break the total number down into blocks of 200 phones and make one SelectCmDevices request per 200 phones.

    Subject: RE: Re: How to get IP address phone having the phone extension
    Replied by: David Staudt on 08-04-2009 01:04:23 AM
    - The Risport service is throttled at 15 requests/minute.  If you attempt more than 15, HTTP 500 is returned until the top of the next minute, when it will start accepting new requests.
     
    - The throttle is geared toward applications using the UCM Publisher (only) for Risport requests.  Spreading Risport requests out amongst UCM nodes means separate throttle daemons can accept more requests overall per minute for the cluster, but this drives the RIS system (which has intern-node query capabilities) beyond its intended rate, and could result in high CPU and impact on call processing.  It is recommended (supported) to use Risport on the Publisher only.  Note, other apps could be using Risport and contributing to the 15 request/min limit.
     
    - By using Admin AXL, you can get a list of all device names (that you are interested in) in the cluster.  You can provide the device name (instead of '*') in SelectCmDevice and get a result for a single device back.  In fact you can specify multiple devices names (up to 200) in SelectCmDevice by simply adding more <Item> elements, and Risport will return the status of each in a single response (be sure and update the count in the array reference.)
     
    - Note, it _is_ possible that a single device has registered to more than one UCM node over time - for example if it registered to Node A, and then experienced a failover or admin re-assignment to Node B.  In that case SelectCmDevice will return _two_ entries for the device: one for the initial registration (with the old IP address and Unregistered status); and one for the current registration (with the latest IP and Registered status.)
     
    - So, if you request 200 devices, and one or several of the devices has registered more than once, then SelectCmDevice response could exceed 200 results, and will be truncated.  To be safe, you will likely want to query somewhat less than 200 devices at a time.
     
    - Yes, this is somewhat problematic   Cisco is looking to improve the way this works in the future.

    Subject: RE: Re: How to get IP address phone having the phone extension
    Replied by: Nataraj Nayak on 08-04-2009 12:20:26 AM
    Hi Stephan
     
        Thanks for the info.  Now I hit a roadblock when I try to query the RIS for IP addresses in a loop using Java.  I have a list of devices and am trying to get the IP for each one of them using Madhukar's method.  For the first 15 devices, the CUCM server returns data properly, but it consistently fails on the 16th call with a HTTP 500 error.  I tried to request with Connection:keep-alive header, but the same result.  I added connection.disconnect() after each call, no help.
     
       Further, we have a cluster of 3 CUCM servers, I try to round-robin each of my 15 sets of calls to them.  Now it consistently fails on the 46th call, when it reaches the first server again.  I also tried adding some delays (Java sleep's) between calls, but in vain. How to solve this problem?
     
       As an alternative, I figured out - instead of using '*' as in Madhukar's example, I can use 'SEP000*', 'SEP001*' etc. to get a subset of the results, count of which is less than 200 in most cases.  But how can I be sure not to miss any device?    Is there any other, more reliable way of filtering you can suggest? 
     
        Also, when you said " break the total number down into blocks of 200 phones and make one SelectCmDevices request per 200 phones.", how do I specify that?  Can I pass a comma-seperated list of devices to one web-service call?  Or is there any way to specify "give me first 200",  "give me 201 to 400" etc?
     
    Thanks
    Nataraj

    Subject: RE: Re: How to get IP address phone having the phone extension
    Replied by: Nataraj Nayak on 08-04-2009 11:12:46 PM
    David
     
         Thanks for the explanation.  I like the idea of adding more <Item> elements in  one SelectCmDevice call - that is exactly what I was looking for.  Now I am trying to send a list of 100 devices at a time.  When you say "be sure and update the count in the array reference", I did not understand what exactly to change.   I changed it as follows,
     
    ....
    <MaxReturnedDevices xsi:type="xsd:unsignedInt">200</MaxReturnedDevices>
    ....
    <SelectItems soapenc:arrayType="ns2:SelectItem[100]" xsi:type="soapenc:Array">
    <item href="#id1"/>
    </SelectItems>
    </multiRef>
    <multiRef id="id1" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns3:SelectItem" xmlns:ns3="http://schemas.cisco.com/ast/soap/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
    <Item xsi:type="xsd:string">SEP001B535D110B</Item>
    <Item xsi:type="xsd:string">SEP001A4B7DA4DA</Item>
    ......
    <Item xsi:type="xsd:string">SEP000F20FD5638</Item>
    <Item xsi:type="xsd:string">SEP001C58415A7D</Item>
    </multiRef>
    </soapenv:Body>
    </soapenv:Envelope>
     
       Whether I change it or not, CUCM is returning the details for only one device, for the last one specified in the <Item> list.  I am sure I am not setting someting else right.  Please let me know what that is.
     
    Thanks
    Nataraj

    Subject: RE: Re: How to get IP address phone having the phone extension
    Replied by: Florian PERVES on 16-11-2009 04:59:56 PM
    Hi there,
     
    I got the same problem as Nataraj, when specifying multiple <item> lines, the return contains information only for the last item specified in the request.
     
    what's wrong ?
     
    my code:
    <?xml version="1.0" encoding="utf-8"?>
            <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <soapenv:Body>
            <ns1:SelectCmDevice soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="http://schemas.cisco.com/ast/soap/">
            <StateInfo xsi:type="xsd:string"/>
            <CmSelectionCriteria href="#id0"/>
            </ns1:SelectCmDevice>
            <multiRef id="id0" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns2:CmSelectionCriteria" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns2="http://schemas.cisco.com/ast/soap/">
            <MaxReturnedDevices xsi:type="xsd:unsignedInt">150</MaxReturnedDevices>
            <Class xsi:type="xsd:string">Phone</Class>
            <Model xsi:type="xsd:unsignedInt">255</Model>
            <Status xsi:type="xsd:string">Registered</Status>
            <NodeName xsi:type="xsd:string" xsi:nil="true"/>
            <SelectBy xsi:type="xsd:string">Name</SelectBy>
            <SelectItems soapenc:arrayType="ns2:SelectItem[150]" xsi:type="soapenc:Array">
            <item href="#id1"/>
            </SelectItems>
            </multiRef>
            <multiRef id="id1" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns3:SelectItem" xmlns:ns3="http://schemas.cisco.com/ast/soap/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"><Item xsi:type="xsd:string">SEP000000000005</Item>
    <Item xsi:type="xsd:string">SEPXXXXXXXXXXX1</Item>
    <Item xsi:type="xsd:string">SEPXXXXXXXXXXX2</Item>
    <Item xsi:type="xsd:string">SEPXXXXXXXXXXX3</Item>
    [...]
    </multiRef></soapenv:Body>
    </soapenv:Envelope>
     
    thanks
    Florian
     
     

    Subject: RE: Re: How to get IP address phone having the phone extension
    Replied by: Florian PERVES on 16-11-2009 11:09:40 PM
    for future reference, I finally found the information there:
    http://developer.cisco.com/web/sxml/forums/-/message_boards/message/1508506;jsessionid=78386E5099FCA64D1D6841CB4A446615.liferay-portal2
     
     
    Florian

    Subject: RE: How to get IP address phone having the phone extension
    Replied by: yiming zhang on 17-11-2009 06:02:54 AM
    Hi:
    I posted the same question in the IP Services foro, but I think this foro is more appropiate.

    I've got the phone extension number from the Active Directory using LDAP, then, I need the IP phone address to make a PUSH data to that phone.

    How can I do this in a simple way?

    thank you in advance,
    marcelo


    hello Marcelo:
            as you say you have get the  extension number from the Active Directory using LDAP. i want to know how you get it for detail. is there any document and sample can you give me.now, i need to get it so.
           thank you.
           best wishes.
           Yiming