Howto:Retrieve configuration of all PBX Objects using SOAP API

From innovaphone-wiki

Jump to: navigation, search

Here is a description of the method how to get the complete PBX Object list and the associated Object configuration as an XML dataset.

Contents

Applies To

This information applies to

  • all PBX platforms

More Information

Problem Details

The SOAP API function Admin can be used to list all PBX Objects and their contents by providing a wild card search parameter * as search string for cn.

However, on the large PBXes with big number of PBX Objects, this may fail, because the system can not deliver all the data in one single batch.

Solution

The solution is to retrieve the data in multiple smaller pages.

Therefore use SOAP API function FindUser to get parts of the PBX Objects list. The best practice is to get PBX Objects names in pages with 50 Objects. Than retrieve the corresponding Object details one by one as XML data set.

An example code based on the Howto:SOAP API PHP5 Sample Code:

$next = false;
$last_user_cn = ""; // start with an empty string to get first objects
while (true) {
 
$users = $inno->FindUser(true, true, true, true, $last_user_cn, null, null, 50, $next, false);
 
if (count($users) == 0) break; // stop, in case no objects delivered
$next = true;
$last_user_cn = end($users)->cn;
 
foreach ($users as $user) { //iterate through the object list
// prepare XML request
// an empty show tag
$show = new SimpleXMLElement("<show/>");
// add the user tag
$user = $show->addChild("user");
// add the "cn" attribute
$user->addAttribute("cn", $user->cn);
// set the config attribute. "true makes sure we get the config as configured only, otherwise, all templates are applied
// weird enough, the opposite would be not config attribute present, a value of "false" will not do!
if ($config) $user->addAttribute("config", "true");
//print "cmd: " . htmlspecialchars($show->asXML()) . "\n";
 
echo $user->cn.":\r\n";
echo ($inno->Admin($show->asXML())); //get XML data of the each particular object
echo "\r\n";
}
}

Known Problems

In scenarios with large amount of PBX Objects, the time to retrieve all PBX Objects data could be longer, cause for every PBX object an own SOAP Admin show request must be performed. E.g. it could take up to 50 seconds to retrieve 2500 PBX Objects including XML data.

Alternatively an HTTP GET request can be used to get all the PBX Objects including XML data. This GET request is located behind the PBX/Config/Export function of the Web GUI:

PBX0/ADMIN/mod_cmd_login.xml?cmd=download&format=xml


Related Articles

Howto:SOAP API PHP5 Sample Code

Reference10:SOAP API

Howto:Using the SOAP Admin Function

Personal tools