ex02_SoaGatewayEmpList.php
<?php
/*
* This example demonstrates usage of the "list" function exposed by any
* Adabas SOA Gateway "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_EmployeesMini?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.
*/
$listkey = array(
'personnel_id' => '',
'first_name' => '',
'name' => '',
'city' => 'CI*');
/*
* 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 "<table border=1 cellpadding=5>";
echo "<tr><th>Personnel Id</th><th>Name</th><th>First Name</th><th>City</th><th width=200>Address Line</td>";
/*
* Loop through all "adabasEmployee" elements, creating a table row for every single one
*/
if ( isset($listresponse->adabasEmployees->adabasEmployee) )
{
$Employees = $listresponse->adabasEmployees->adabasEmployee;
if (!is_array($Employees))
$Employees = $listresponse->adabasEmployees;
foreach ($Employees as $Employee) {
echo "<tr><td>$Employee->personnel_id</td><td>$Employee->name</td><td>",
"$Employee->first_name</td><td>$Employee->city</td><td>";
echo "<table>";
/*
* Format the "address_line" element (a MU(ltiple value field)) as a table within the table
*/
if (!is_array($Employee->address_line)) {
echo "<tr><td width=200>$Employee->address_line</td></tr>";
} else {
foreach ($Employee->address_line as $addr) {
echo "<tr><td width=200>$addr</td></tr>";
}
}
echo "</table>";
echo "</td></tr>";
}
}
/*
* Proceed to ex03_SoaGatewayEmpAdd.php - Add a new employee record
*/
?>