Android : KSOAP2 NUSOAP PHP complexType array android

on Saturday, December 13, 2014


I'm getting a weird error with my APP.


Everything on my WS works when I call the function to retrieve a array from a * nusoap_client`. If I do that on android, it returns null.


But, if I make my SQL call and it doesn't have any value and return a empty array, my android receive.


With an array with values it returns null and on my response envelope I get the message:



unterminated entity ref (position:TEXT @1:201 java.io.InputStreamReader@something)



My NUSOAP Code:



$server->wsdl->addComplexType(
"Ticket",
"complexType",
"struct",
"all",
"",
array(
"id" => array("name" => "ID", "type" => "xsd:integer"),
"status" => array("name" => "status", "type" => "xsd:integer"),
"titulo" => array("name" => "titulo", "type" => "xsd:string"),
"descri" => array("name" => "descri", "type" => "xsd:string"),
"sala" => array("name" => "sala", "type" => "xsd:string"),
"userOpen" => array("name" => "userOpen", "type" => "xsd:string"),
"tecnico" => array("name" => "tecnico", "type" => "xsd:string"),
"horaAbertura" => array("name" => "horaAbertura", "type" => "xsd:string"),
"horaCompleto" => array("name" => "horaCompleto", "type" => "xsd:string")
)
);

$server->register("getTickets",
array("query" => "xsd:string"),
array("return"=>"tns:TicketArray"),
$namespace,
$namespace ."#arrayChamados",
"rpc",
"encoded",
"List Chamados");


PHP code:



function getTickets($query) {
global $db;

$findNewTickets = mysqli_query($db, "SELECT * FROM fserv_chamados WHERE userOpen = '$query'");

if (!$findNewTickets) {
die("Erro ao localizar: ". mysqli_error($db));
} else {
$arr = array();
while($linha = mysqli_fetch_assoc($findNewTickets)) {
$arr[] = array(
'id' => removeAccents($linha['ID']),
'status' => removeAccents($linha['status']),
'titulo' => removeAccents($linha['titulo']),
'descri' => removeAccents($linha['descri']),
'sala' => removeAccents($linha['sala']),
'userOpen' => removeAccents($linha['userOpen']),
'tecnico' => removeAccents($linha['tecnico']),
'horaAbertura' => removeAccents($linha['horaAbertura']),
'horaCompleto' => removeAccents($linha['horaCompleto'])
);
}
}
return $arr;
}

0 comments:

Post a Comment