0
我正在研究一個需要Java和PHP技術的項目。我使用Java來實現業務邏輯和數據源管理,而PHP有助於使用我使用Java提供的Web服務。 我的問題: 當我使用來自Web服務的響應並且結果包含多個返回集合時,程序運行良好。 (http://driesmeers.mamca.be/images/successpage.png) 但是,一旦結果只返回一個集體回覆,我收到一個錯誤,如下所示。 (http://driesmeers.mamca.be/images/errorpage.png)錯誤:注意:試圖獲取非對象的屬性
這裏是我的code.PHP
<?php
try {
$wsdl_url = 'http://localhost:8080/Mamca/MamcaWS?WSDL';
$client = new SOAPClient($wsdl_url);
$params = array(
'projectid' => $_SESSION['projectID'],
);
$return = $client->getAlternativeListByProjectID($params);
if (isset($return->return)) {
foreach ($return->return as $eachItem) {
echo "<tr align='center'>";
echo "<td align='left' class='rowDisplay'> <a href = '#' class = 'rowNumber2'>" . $eachItem->alternativedescription . "</a></td>";
echo "<td align='left' class='rowDisplay'>" . $eachItem->alternativeGroup . "</td>";
echo "<td align='left' class='rowDisplay'>";
echo ($eachItem->status === 1 ? 'Active' : 'Inactive');
echo "</td>";
echo "<td align='center' class='rowDisplay'><img src = '../images/icons/delete.png' longdesc = 'http://.delete' /><img src = '../images/icons/table_edit.png' width = '16' height = '16' /></td>";
echo "</tr>";
}
}
} catch (Exception $e) {
echo "Exception occured: " . $e;
}
?>
<tr id="ajax_response">
</tr>
從WS響應與錯誤輸出:
<?xml version="1.0" encoding="UTF-8"?><S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/>
<S:Body>
<ns2:getAlternativeListByProjectIDResponse xmlns:ns2="http://services.mamca.be.vub/">
<return>
<alternativeGroup>testt</alternativeGroup>
<alternativedescription>testtt</alternativedescription>
<alternativeid>10670</alternativeid>
<id>19</id>
<projectid>12313</projectid>
<status>1</status>
</return>
</ns2:getAlternativeListByProjectIDResponse>
</S:Body>
</S:Envelope>
我如何解決這個問題?謝謝。
,你這麼多,它的工作。 – 2014-10-09 11:18:07