NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
Register an array of string


Joined: 18 Sep 2015
Posts: 1
Reply with quote
Hello everybody,
i want to return a string array in my web service but i always get
Code:

{"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
Code:

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
Code:

$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
Code:

$json = array("status"=>"ok","data"=>$client->call('getCategories',array()));
        echo json_encode($json);

Thank you
View user's profileFind all posts by jdtotowSend private message
Register an array of string
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