Joined: 18 Sep 2015 |
Posts: 1 |
|
|
|
Posted: Fri Sep 18, 2015 11:33 am |
|
|
|
|
|
Hello everybody,
i want to return a string array in my web service but i always get
{"status":"ok","data":false}
|
as a json result, there is no error in the result , just false in place of some array. I'm using lampp on Ubuntu 15.04
Thank you,
This is my function
function getCategories()
{
$db = new PDO('mysql:host=localhost;dbname=mydb','root', '');
$request = 'SELECT id,name FROM category';
$answer = $db->query($request);
//$result = array();
while($data = $answer->fetch())
{
$items[] = array('id_cat'=>$data['id'],'name_cat'=>$data['name']);
}
return $items;
}
|
my service.php
$server->wsdl->addComplexType(
'Category',
'complexType',
'struct',
'all','',
array(
'id' => array('name' => 'id_cat', 'type' => 'xsd:int'),
'name' => array('name' => 'name_cat', 'type' => 'xsd:string')
)
);
$server->wsdl->addComplexType(
'CategoryArray',
'complexType',
'array','',
'SOAP-ENC:Array',array(),
array(
array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'tns:Category[]')
),
'tns:Category'
);
$server->register("getCategories",array(),array("return"=>'tns:CategoryArray'));
|
and i have this in the client.php
$json = array("status"=>"ok","data"=>$client->call('getCategories',array()));
echo json_encode($json);
|
Thank you
|
|