Portus Version 2018-08-24
 

List by Super Descriptor (ex06_SoaGatewaySpecial_SuperDescriptor.php)

<?php

/*
 *  This example demonstrates usage of the "list" function exposed by any
 *  Adabas Portus "WebService" from PHP, retrieving selected records
 * from the Adabas demo file "Employees", and formatting it, in 4 easy steps.
 */


/*
 *  Step 1: Instantiate the PHP "SoapClient" class
 */
try {
 $soapclient = new SoapClient("http://localhost:8022/adabas_Employees_special?WSDL");
} catch (SoapFault $soapfault) {
 echo "<pre>";
 print_r($soapfault);
 echo "</pre>";
 return;
}

/*
 *  Step 2: Build the key ("descriptor") array, due to parser requirements ALL
 *    key elements need to be specified, but elements may be left empty
 *    when unused. Here we are using the SUB-descriptor "department".
 */
$listkey = array(
 'personnel_id' => "",
 'first_name' => "",
 'name'   => "",
 'birthday'  => "",
 'city'   => "",
 'dept'=> "",
 'job_title'  => "",
 'language_spoken'=>"",
 'leave_left' => "",
 'dept_person' => array('dept' => "MGMT10", 'name' => "K*"),
 'currency_salary'=> "",
 'department' => "",
 'phonetic_name' => "");

/*
 *  Step 3: Execute the "list" request, passing the key array as the only parameter,
 *    the response object will consist of an "adabasEmployees" element containing
 *    an array of "adabasEmployee" elements.
 */
try {
 $listresponse = $soapclient->list($listkey);
} catch (SoapFault $soapfault) {
 echo "<pre>";
 print_r($soapfault);
 echo "</pre>";
 return;
}

/*
 *  Step 4: Format the Employee records nicely into a HTML table.
 */

echo "Find all Employees in department group 'MGMT10' whose names start with 'K' - using an Adabas SUPER-Descriptor<br><br>";
echo "<table border=1 cellpadding=5>";
echo "<tr><th>Personnel Id</th><th>Name</th><th>First Name</th><th>City</th><th>Department</td>";

/*
 *  Loop through all "adabasEmployee" elements, creating a table row for every single one
 */
foreach ($listresponse->adabasDemoEmployeesSpecial->demoEmployeeSpecial as $Employee) {
 echo  "<tr><td>$Employee->personnel_id</td><td>$Employee->name</td><td>",
   "$Employee->first_name</td><td>$Employee->city</td><td>$Employee->department_code</td>";
 echo "</td></tr>";
}

/*
 *  Proceed to ex03_SoaGatewayEmpAdd.php - Add a new employee record
 */
?>

Ostia
www.ostiasolutions.com
Copyright @ 2006-2018 Ostia Software Solutions Limited.