php SOAP之多層complex型別
阿新 • • 發佈:2019-01-26
<?php
$client = new SoapClient("http://www.example.com/Xservice.php?WSDL", array('trace'=>true));
$cardUID = array('ARN'=>'100000000000002', 'expiryDate'=>2044);
$locationAccess10 = array(
'accessPermission'=>'ALLOW',
'project'=>'CASA BELLA',
'building'=>'MAGNIFICA',
'wing'=>'C' ,
'door'=>'301'
);
$locationAccess11 = array(
'accessPermission'=>'ALLOW',
'project'=>'CASA BELLA',
'building'=>'MAGNIFICA',
'wing'=>'E',
'door'=>'302'
);
$locationAccessS = array($locationAccess10, $locationAccess11);
$cardInfo1 = array(
'residentID' =>'1000010',
'cardUID'=>$cardUID,
'accessExpiryDate'=>'24/03/2016',
'locationAccess'=>$locationAccessS
);
$cardUID2 = array('ARN'=>'000000011479FFFFFFFFFFFFFFFFFF', 'expiryDate'=>2044);
$locationAccess20 = array(
'accessPermission'=>'ALLOW',
'project'=>'CASA BELLA',
'building' =>'MAGNIFICA',
'wing'=>'C',
'door'=>'302'
);
$locationAccessS2 = array($locationAccess20);
$cardInfo2 = array(
'residentID'=>'1000011',
'cardUID'=>$cardUID2,
'accessExpiryDate'=>'24/03/2016',
'locationAccess'=>$locationAccess20
);
$cardUID3 = array('ARN'=>'100000000000004', 'expiryDate'=>2045);
$cardInfo3 = array(
'residentID'=>'1000013',
'cardUID'=>$cardUID3,
'accessExpiryDate'=>'24/03/2016',
);
$cardInfo = array($cardInfo1,$cardInfo2,$cardInfo3);
try {
$response = $client->AddAccessCardDetails(array('messageId'=>rand(), 'cardInfo'=>$cardInfo));
print_r($response);
}catch (SoapFault $e){
echo '<h2>Debug</h2>';
echo $e->getMessage();
}
echo '<h2>Request</h2>';
echo '<pre>'.htmlspecialchars($client->__getLastRequest(), ENT_QUOTES).'</pre>';
echo '<h2>Response</h2>';
echo '</pre>'.htmlspecialchars($client->__getLastResponse(), ENT_QUOTES).'</pre>';
?>