NuSphere Forums Forum Index
NuSphere Forums
Reply to topic

Creating Web Service in php using nusoap(fetching data from mysql)
php,
0%
 0%  [ 0 ]
nusoap
0%
 0%  [ 0 ]
web service
0%
 0%  [ 0 ]
Total Votes : 0

Fault Error: unable to serialize result


Joined: 24 Jul 2013
Posts: 2
Location: HYD
Reply with quote
Hi all,

I am learning php.

I have created Web Service in php using nusoap.dll. I have written price test method it's return integer it's working fine, but when I fetch database, to return array it's returning error. I had tried to resolve the error, but it's still giving error.

Could you tell me where I went wrong.

my php code is:
//service.php

<?php

/**
* @author
* @copyright 2013
*/

require 'lib/nusoap.php';
require 'functions.php';

$server = new nusoap_server();
$server -> configureWSDL('WS'.'urn:WS');
$server -> register(
"price", //name of the function
array("name" => 'xsd:string'), //inputs
array("return" => 'xsd:inter') //outputs
);

$server -> register(
"ReadBooks", //name of the function
array("productid" => 'xsd:inter'), //inputs
array("return" => 'xsd:unbounded') //outputs
);

/**
* $server -> register(
* "countbooks", //name of the function
* array(), //inputs
* array() //outputs
* );
*/

$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
$server->service($HTTP_RAW_POST_DATA);

?>

//functions.php

<?php

/**
* @author
* @copyright 2013
*/

function price($name){

$details=array('abc'=>100,
'xyz'=>200);
foreach($details as $n => $p){
if($name==$n){
$prices = $p;
}
}
return $prices;
}

function ReadBooks($productid)
{
mysql_connect("localhost","root","") or die(mysql_error());
mysql_select_db("Sample") or die(mysql_error());
$myQuery='Select * from php_shop_products where product_id='.$productid;
$results = mysql_query($myQuery);
if($results===false){
return die($myQuery."<br/><br/>".mysql_error());
}
else{
return $results;
}
return die(mysql_error());
}

/*$results =ReadBooks(1);

while($row =mysql_fetch_array($results)){
echo $row['name'];
}*/


?>

//client.php

<?php

/**
* @author
* @copyright 2013
*/

require 'lib/nusoap.php';

$client = new nusoap_client("http://localhost:8080/myfiles/examples/WS/service.php?wsdl");
$book_name="xyz";
$prices=$client->call('price',array("name"=>"$book_name"));

echo $prices . '<br/>';


$productid=1;
$results=$client->call('ReadBooks',array("productid"=>$productid));

while($row =mysql_fetch_array($results)){
echo $row['name'];
}



?>



it's returning error:

First function result : 200 //success

//second function error

Fault:

Array
(
[faultcode] => SOAP-ENV:Server
[faultactor] =>
[faultstring] => unable to serialize result
[detail] =>
)


Could you tell me where I went wrong.

Thanks in advance..........
View user's profileFind all posts by ManojSend private message
Fault Error: unable to serialize result
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