hi all,
I got one question about the data retrieval in SOAP and PHP 5. I am able to retrieve one row of data.the problem is, when there is more than 1 match data, it only shows the first row of the data.i am not able to view all the data.I have no idea why it cant show all the match data. I have been trying to find out the solution for the past 2 days but sadly it gave me no luck 😕
I hope somebody can help me out from this problem and thank you very much.
Regards,
Kencana
the following is my SOAP client code:
<?php
$symbol=$_GET['address'];
$client = new SoapClient("stockquote3.wsdl",array(
"trace" => 1,
"exceptions" => 0));
try
{
$result=array();
$courses=array();
$result= $client->getQuote($symbol);
$courses= array('Road_name' => $result);
foreach ($courses as $name)
{
echo "Your Address is:\n";
print $name;
echo "<br>\n";
}
}
catch (SoapFault $exception)
{
echo "wrong user";
}
//print ($client->getQuote($symbol));
?>
while the following is my SOAP server code:
<?php
class QuoteService {
function getQuote($symbol){
if ($symbol=='')
{
return "invalid postal code";
}
else
{
mssql_connect ("localhost","user","password");
mssql_select_db ("Address");
$query = "SELECT * from Road WHERE Postal_code LIKE '$symbol%'";
$result = mssql_query($query);
$i=0;
$count=mssql_num_rows ( $result );
$courses = array();
while($course = mssql_fetch_assoc($result))
{
$courses= array('Road' => $course["Road_name"]);
foreach ($courses as $road)
{
return $road;
}
}
}
}
}
//ini_set("soap.wsdl_cache_enabled", "0"); // disabling WSDL cache
$server = new SoapServer("stockquote3.wsdl");
$server->setClass("QuoteService");
$server->handle();
?>