我創建了以下PHP腳本來顯示我們使用的SOAP API中的屬性列表。PHP分析SOAP響應的問題
當我們有多個屬性被廣告時,該腳本正常工作,但是當我們只有一個屬性被廣告時什麼也沒有顯示。
任何人都可以告訴我我做錯了什麼或一個簡單的檢查,可以解決問題嗎?
我的代碼是:
$wsdl = "http://portal.letmc.com/PropertySearchService.asmx?WSDL";
$client = new SoapClient($wsdl, array ("trace"=>1, "exceptions"=>0));
$strClientID = "{xxxx-xxxx-xxxx-xxxx}";
$strBranchID = "{xxxx-xxxx-xxxx-xxxx}";
$nMaxResults = "5";
$nRentMinimum = 100;
$nRentMaximum = 900;
$nMaximumTenants = 5;
$parameters = array( "strClientID"=>$strClientID,
"strBranchID"=>$strBranchID,
"nMaxResults"=>$nMaxResults,
"nRentMinimum"=>$nRentMinimum,
"nRentMaximum"=>$nRentMaximum,
"nMaximumTenants"=>$nMaximumTenants
);
$values = $client->SearchProperties($parameters);
if($values != '')
{
echo "<table>";
echo '<tr>
<th>Apartment</th>
<th class="center">Bedrooms</th>
<th>Rent</th>
<th>Description</th>
</tr>';
foreach ($values->SearchPropertiesResult->PropertyInfo as $message)
{
$address = $message->Address1;
$rooms = $message->MaxTenants;
$rent = $message->Rent;
$description = $message->Description;
echo '<tr>';
echo '<td>'. $address .'</td>
<td class="center">'. $rooms .'</td>
<td>'. $rent .'</td>
<td>'. $description .'</td>';
echo '</tr>';
}
echo '</table>';
}
else
{
echo '<p><strong>Sorry, we have no properties available.</strong></p> <p>Please register your details on the right and we will let you know as soon as an apartment comes available.</p>';
}
工作過的一種享受 - 謝謝! –