cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
3109
Views
7
Helpful
13
Replies
Highlighted
Beginner

Risport retrieval failure - PHP

Dear folks,

When trying to fetch device status via RisPort using PHP, I get the following error:

Error the cmSelectionCriteria is null

Interestingly, I have a working version written in python.

Both of them are as below:

PHP:

<body>

<div class="container-fluid">

<?php

include "utils.php";

$client = new SoapClient("rispost.wsdl",

  array('trace'=>true,

   'exceptions'=>true,

   'location'=>"https://".$host.":8443/realtimeservice/services/RisPort",

   'login'=>$username,

   'password'=>$password,

   'connection_timeout'=>60,

   'stream_context' => $context,

   'trace' => 1

));

try

{

  $devices = $client->SelectCmDevice(

     "",

     array(

         "SelectBy" => "Name",

         "Status" => "Registered",

     )

);

}

catch (SoapFault $e)

{

  echo "Cannot call method: {$e->getMessage()}";

}

?>

</div>

</body>

</html>

--

Python:

from suds.client import Client

from suds.xsd.doctor import Import, ImportDoctor

import logging

import Basic

import ssl

ssl._create_default_https_context = ssl._create_unverified_context

wsdl = 'https://172.16.4.200:8443/realtimeservice/services/RisPort?wsdl'

cmport = '8443'

#wsdl = 'http://172.17.1.30/AXLAPI.wsdl'

#location = 'https://' + cmserver + ':' + cmport + '/axl/'

import getpass

user = input('user:')

pwd = getpass.getpass('pwd:')

print ('Loading...')

imp = Import('http://schemas.xmlsoap.org/soap/encoding/')

doctor = ImportDoctor(imp)

print('Loading...\n')

client = Client(url=wsdl, username=user, password=pwd, doctor=doctor)

result = client.service.SelectCmDevice('',{'SelectBy':'Name', 'Status':'Registered', 'Class':'Phone', 'Model':'255'})

print('\tDevice\t\tIP Address\tDescription\n\n')

for node in result['SelectCmDeviceResult']['CmNodes']:

    for device in node['CmDevices']:

        print ('\t'+device['Name'] +'\t'+ device['IpAddress'] +'\t'+ device['Description'])

print('\n\n')

Any ideas?

Regards

Andre Castro

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

Attached is a complete project based on your code.  This works for me against CUCM 10.5.  Note, the WSDL file is the one retrieved from https://cucm-host:8443/realtimeservice/services/RisPort?wsdl

It looks like the WSDL is different (and requires changes to the PHP code) if you use the WSDL retrieved from https://cucm-host:8443/realtimeservice2/services/RISService70

View solution in original post

13 REPLIES 13
Highlighted
Cisco Employee

Looks like the parameters to SelectCmDevice() need to be wrapped in an array(), i.e.:

try

{

  $devices = $client->SelectCmDevice( array(

        "",

        array(

            "SelectBy"=>"Name",

            "Status"=>"Registered"

        )

     )

);

}

catch (SoapFault $e)

{

  echo "Cannot call method: {$e->getMessage()}";

}

The above works fine on my 10.5 setup (using Risport70 WSDL and service)

Highlighted

Thanks dstaudt!

I think I tried that someday too.. Now it seems to complain about the missing first argument:

Cannot call method: SOAP-ERROR: Encoding: object has no 'StateInfo' property

Regards

Andre

Highlighted

Not sure how I tested the wrong code, but can you try this:

  $devices = $client->SelectCmDevice( array(

        "StateInfo"=>"",

        "CmSelectionCriteria"=>array(

            "Status"=>"Any",

            "SelectBy"=>"Name",

            "SelectItems"=>""

        )

     )

);

Highlighted

Thanks once again dstaudt..

It seems you´re right, we need to actually "declare" the attributes we want to pass on to the request.

Now I got another issue which I´m not able to solve (no info on Google =/)

Cannot call method: org.xml.sax.SAXException: Invalid element in com.cisco.ccm.serviceability.soap.risport.CmSelectionCriteria - DeviceClass

Thanks heaps once again

Cheers

Andre

Highlighted

Can you paste the code that's not working? (Ideally the full program file)

Highlighted

Yes, besides the code from the initial message, I include the following file:

utils.php:

<!DOCTYPE html>

<html lang="en">

<head>

  <title>Multirede UCAT</title>

  <meta charset="utf-8">

  <meta name="viewport" content="width=device-width, initial-scale=1">

  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">

  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>

  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>

</head>

<?php

// phpinfo();

$context = stream_context_create([

    'ssl' => [

        // set some SSL/TLS specific options

        'verify_peer' => false,

        'verify_peer_name' => false,

        'allow_self_signed' => true

    ]

]);

$host="XXXXX";

$username="XXXX";

$password="XXXX";

?>

status.php:

<body>

<div class="container-fluid">

<?php

include "utils.php";

$client = new SoapClient("rispost.wsdl",

  array('trace'=>true,

   'exceptions'=>true,

   'location'=>"https://".$host.":8443/realtimeservice/services/RisPort",

   'login'=>$username,

   'password'=>$password,

   'connection_timeout'=>60,

   'stream_context' => $context,

   'trace' => 1

));

try

{

  $devices = $client->SelectCmDevice(

     "",

     array(

         "SelectBy" => "Name",

         "Status" => "Registered",

     )

);

}

catch (SoapFault $e)

{

  echo "Cannot call method: {$e->getMessage()}";

}

?>

</div>

</body>

</html>

Cheers

Andre

Highlighted

Please try wrapping the arguments to $client->SelectCmDevice() in an (another) array, as below:

      $devices = $client->SelectCmDevice( array(

            "StateInfo"=>"",

            "CmSelectionCriteria"=>array(

                "Status"=>"Any",

                "SelectBy"=>"Name",

                "SelectItems"=>""

            )

         )

    );

I also had to include the StateInfo and SelectItems empty values as placeholders to get mine to work.

Highlighted

I tried that as well, unsuccessfully.

I get the error from my previous post

Driving me mad!

Cheers

Andre

Highlighted

Attached is a complete project based on your code.  This works for me against CUCM 10.5.  Note, the WSDL file is the one retrieved from https://cucm-host:8443/realtimeservice/services/RisPort?wsdl

It looks like the WSDL is different (and requires changes to the PHP code) if you use the WSDL retrieved from https://cucm-host:8443/realtimeservice2/services/RISService70

View solution in original post

Highlighted

Thank you dstaudt, your example works just fine! There must be something wrong with the WSDL provided in CUCM 11.5

The funny thing is that the same WSDL works fine in my Python script.

Cheers mate, thanks a lot for your help!

Andre Castro

Highlighted

Hello,

I have it working with CUCM 11.5 using your script status.php

<?php

include "utils.php";

$client = new SoapClient("risport.wsdl",

  array('trace'=>true,

   'exceptions'=>true,

   'location'=>"https://".$host.":8443/realtimeservice2/services/RISService70?wsdl",

   'login'=>$username,

   'password'=>$password,

   'connection_timeout'=>60,

   'stream_context' => $context,

   'trace' => 1

));

try

{

   $devices = $client->SelectCmDevice( array( 

            "StateInfo"=>"", 

            "CmSelectionCriteria"=>array( 

                "Status"=>"Any", 

                "SelectBy"=>"Name", 

                "SelectItems"=>"" 

            ) 

         ) 

    );

 

 

  echo "<pre>";

  print_r($devices);

  echo "</pre>";

}

catch (SoapFault $e)

{

  echo "Cannot call method: {$e->getMessage()}";

}

?>

only changed the location variable as described by dstaudt

Highlighted
Beginner

Python script returning results only for 2000 phones, Is there any way to get more than 2000 phones ?
I tried increasing <MaxReturnedDevices xsi:type="xsd:unsignedInt">10000</MaxReturnedDevices> but no luck. I have total of 10k phones in RIS database.
Highlighted

Unfortunately the enforced limit is 1000 (or 2000 as you've observed, for later CUCM versions.)

For situations with more than the max allowable, it is recommended to compile a list of device names (e.g. using AXL <listPhone>) and use SelectCmDeviceExt passing in a chunk of phone names per request, in order to page through the list.

See 'Using RisPort70 With Bulk Requests': https://developer.cisco.com/docs/sxml/#!risport70-api-reference