NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
[resolved] NuSoap returning nothing


Joined: 20 Feb 2008
Posts: 2
Reply with quote
Hi I have a function with two parameters. $vehicle and $name to know who to reply to and why type of vehicle to update. my service code is as follows

Code:
function bookVehicle($vehicle, $name){

    $conn = mysql_connect('localhost', 'root') or die('Something wrong');
    if(!$conn){
        return "Couldn\'t connect to the db";
    }
   
    $dbname = 'tomsbikes';
    mysql_select_db($dbname, $conn);
   
    $update= 'UPDATE '.$vehicle.' SET amount = amount-1 WHERE amount != 0';
   
    $result = mysql_query($update, $conn);
   
    while($row = mysql_fetch_array($result)){
        $value = $row['type'];
        $cost = $row['price'];
        mysql_close($conn);
        return "Congratulations " .$name. " you have succesflully booked a ".$type." vehicle costing: ".$cost;
    }
}


I know I am not returning the results from the database properly, this is not a big issue for this project;
My client side code is:
Code:

$rentalName = $_REQUEST["rental"];
    $name = $_REQUEST["firstname"];
    $vehicle = $_REQUEST["vehicle"];
    require_once('nusoap.php');
   
        $s = new nusoap_client("http://localhost/DistSys/".$rentalName.".php?wsdl",true);
        $proxy = $s->getProxy();
        $result = $proxy->bookVehicle($vehicle, $name);
        echo '<h1 class="color">'.$result.'</h1>';

   


The way i am registering the function is:
Code:
$s->register('bookVehicle',
array('vehicle' => 'xsd:string', 'name' => 'xsd:string'),
array('return' => 'xsd:String'),
$ns);



The problem is that the mysql update query executes fine, but it does not return the string to echo. All other functions from this service work fine.
Can any one see what the problem would be.[/code]
View user's profileFind all posts by abbottvSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8334
Reply with quote
try to change this
Code:
$s = new nusoap_client("http://localhost/DistSys/".$rentalName.".php?wsdl",true);
$proxy = $s->getProxy();
$result = $proxy->bookVehicle($vehicle, $name);

to code below
Code:
$s = new nusoap_client("http://localhost/DistSys/".$rentalName.".php?wsdl",true);
$result = $s->call('bookVehicle', array($vehicle, $name));

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website


Joined: 20 Feb 2008
Posts: 2
Reply with quote
I figured out the problem. I had a UPDATE query which wasn't returing any values, therefore the while never happened.
Another issue was returning arrays, the client could never access what I was returning. Any one else have this problem?
View user's profileFind all posts by abbottvSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8334
Reply with quote
please check for samples. There was one or two returning arrays.

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website
[resolved] NuSoap returning nothing
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT - 5 Hours  
Page 1 of 1  

  
  
 Reply to topic