ex03_SoaGatewayEmpAdd.php

<?php

/*
 * 	We now add a new Employee record, which is just as simple.
 */
	 
try{
	$soapclient = new SoapClient("http://localhost:8022/adabas_EmployeesMini?WSDL");
} catch (SoapFault $soapfault) {
	printSoapFault($soapclient, $soapfault);
	return;
}

/*
 * 	Constructing the "data record" is similar to building the key array
 * 	for a "list" operation, MUs are represented by an array within the
 * 	array.
 */
$adabasEmployee = array (
	'personnel_id'	=> '99999999',
	'first_name'		=> 'Kirk',
	'name'			=> 'Newlyadded',
	'city'	 		=> 'City',
	'address_line'	=> array ('route 66', 'from here', 'to there', 'CA')
);

/*
 * 	The expected structure is equivalent to the one returned by "list",
 * 	thus we need to create an array of "adabasEmployee" elements, even
 * 	though there is just one:
 */
$adabasEmployees = array($adabasEmployee);

/*
 * 	Now add the Employee
 */
try {
	$Adabasresponse = $soapclient->add($adabasEmployees);
} catch (SoapFault $soapfault) {
	printSoapFault($soapclient, $soapfault);
	return;
}

/*
 * 	An "add" results in a "short response", print the message:
 */
echo "<pre>result: $Adabasresponse->results</pre>";

/*
 * 	The SOAPFault is handled in a function:
 */
function printSoapFault ($soapclient, $soapfault) {
	echo "<pre>";
	echo "\n\nSoap Fault occurred\n\nFaultCode..: ".$soapfault->faultcode."\nFaultString: ".$soapfault->faultstring;
	echo "</pre>";	
}

/*
 * 	Proceed to ex04_SoaGatewayEmpGet.php - Get and display the newlyadded employee record
 */
?>