[eluser]Unknown[/eluser]
Hello everybody, I'm creating a class-XMLRPC server to communicate with a client is apparently all right, my client sends the request to the API (web service) then he loads the library, send the run method and the model carries a one to query the database, but when I send data from the server back to the client, it always brings me an error this one:
The XML data received was either invalid or not in the correct form for XML-RPC. Turn on debugging to examine the XML data further.
-----------------------------------------------------------------
Following is the code of the classes below:
Client
Code:
public function authNew($data){
$this->CI->load->library('xmlrpc');
$this->CI->config->load('chefao',TRUE,TRUE);
$server_url = $this->CI->config->item("server_url","chefao");
$this->CI->xmlrpc->server($server_url, "80");
$this->CI->xmlrpc->method('user.insert');
// $this->CI->xmlrpc->set_debug(true);
$this->CI->xmlrpc->timeout(60);
$time = time();
$request = array(
array(
array(
'id_status' => $data['id_status_fk'],
'id_pessoa' => $data['id_pessoa_fk'],
'email' => $data['email'],
'senha' => $data['senha'],
), "struct"
)
);
$this->CI->xmlrpc->request($request);
if (!$this->CI->xmlrpc->send_request()) {
echo $this->CI->xmlrpc->display_error();
} else {
echo '<pre>';
print_r($this->CI->xmlrpc->display_response());
echo '</pre>';
}
}
API:
Code:
class Api extends CI_Controller {
public function __construct() {
parent::__construct();
$this->load->library('xmlrpc');
$this->load->library('xmlrpcs');
}
function index() {
// $this->load->library('xmlrpc');
// $this->load->library('xmlrpcs');
$this->load->library('authentication/Authentication');
// $this->load->library('people/People');
// $this->load->library('customer/Customer');
$config['functions']['authentication.insert'] = array('function' => 'authentication.save');
$config['functions']['authentication.update'] = array('function' => 'authentication.update');
$config['functions']['authentication.delete'] = array('function' => 'authentication.delete');
// $config['functions']['customer.insert'] = array('function' => 'authentication.save');
// $config['functions']['customer.delete'] = array('function' => 'authentication.delete');
// $config['functions']['people.insert'] = array('function' => 'people.save');
$config['functions']['auth.getAll'] = array('function' => 'authentication.listAuth');
$config['object'] = $this;
$this->xmlrpcs->initialize($config);
$this->xmlrpcs->serve();
}
}
Library:
Code:
public function listAuth(XML_RPC_Message $request){
$ci =& get_instance();
$ci->load->model("autenticacao_model", 'user');
$ci->user = new autenticacao_model();
$parameters = $request->output_parameters();
$res = $ci->user->listAll();
if($res == NULL){
echo $this->CI->xmlrpc->display_error();
} else{
$authListar = array();
foreach ($res as $user){
$authListar[$user["id_autenticacao"]] =
array(
array(
array(
'id_autenticacao' => array($user['id_autenticacao'], 'int'),
'id_status_fk' => array($user['id_status_fk'], 'int'),
'id_pessoa_fk' => array($user['id_pessoa_fk'], 'int'),
'email' => array($user['email'], 'string'),
'senha' => array($user['senha'], 'string'),
'ultimo_acesso' => array($user['ultimo_acesso'], 'string'),
'status' => array($user['status'], 'string'),
),'struct'
),
);
}
$response = array($authListar, 'array');
print_r($response);die;
}
return $ci->xmlrpc->send_response($response);
}
My model:
Code:
public function listAll() {
$this->db->select("auth.*, auth_status.nome_status as status")
->from("autenticacoes auth")
->join("autenticacoes_status as auth_status","auth_status.id_status = auth.id_status_fk")
->join("pessoas as p", "p.id = auth.id_pessoa_fk");
$res = $this->db->get();
if($res->num_rows() == 0 ){
return NULL;
}
else{
$res = $res->result_array();
}
return $res;
}