Welcome Guest, Not a member yet? Register   Sign In
XMLRPC - Root element missing
#1

I'm trying to convert some procedural code for handling xmlrpc requests into codeigniter, but when following the example on how to properly setup an xmlrpc server within codeigniter the client responds with an error saying that the Root element is missing from the request.

The procedural code is as follows:


PHP Code:
$xmlrpc_server xmlrpc_server_create();
xmlrpc_server_register_method($xmlrpc_server"reportuser",
 
                         "reportuser");

function 
reportuser($method_name$params$app_data)
{
 
 global $db;

 
 $req        $params[0];

 
 $regionName = (string)$req['regionName'];
 
 $abuserID = (string)$req['abuserID'];
 
 $catagory = (int)$req['catagory'];
 
 $checkflags = (int)$req['checkflags'];
 
 $details = (string)$req['details'];
 
 $objectID = (string)$req["objectID"];
 
 $postion = (string)$req['postion'];
 
 $reportType = (int)$req['reportType'];
 
 $screenshotID = (string)$req['screenshotID'];
 
 $Summary = (string)$req['Summary'];
 
 $reporter = (string)$req['reporter'];

 
$query $db->prepare("INSERT INTO reports VALUES (NULL, NOW(), '$regionName', '$abuserID', $catagory$checkflags, '$details', '$objectID', '$postion', $reportType, '$screenshotID', '$Summary', '$reporter')");
$result $query->execute();

 
 $response_xml xmlrpc_encode(array(
 
   'success'      => $result,
 
   'errorMessage' => get_error_message($result)
 
 ));

 
 print $response_xml;
}

$request_xml file_get_contents("php://input");

xmlrpc_server_call_method($xmlrpc_server$request_xml'');
xmlrpc_server_destroy($xmlrpc_server); 


My attempt at conversion into codeigniter:


PHP Code:
public function index()
 
   {

 
       $this->load->library('xmlrpc');
 
       $this->load->library('xmlrpcs');

 
       $config['functions']['reportuser'] =  array('function' => 'Report.reportuser');
 
       $config['object'] = $this;
 
       $config['xss_clean'] = FALSE;

 
       $this->xmlrpcs->initialize($config);
 
       $this->xmlrpcs->serve();

 
   }

 
   public function reportuser($request)
 
   {
 
       $this->load->library('xmlrpc');

 
       $zsite $this->load->database('grid'TRUE);
 
       $parameters $request->output_parameters();


 
       $data $parameters;
 
       $zsite->query("INSERT INTO TEST VALUES ('$data')");     

        $params 
$parameters[0];


 
       $regionName = (string)$params['regionName'];
 
       $abuserID = (string)$params['abuserID'];
 
       $category = (int)$params['catagory'];
 
       $checkflags = (int)$params['checkflags'];
 
       $details = (string)$params['details'];
 
       $objectID = (string)$params["objectID"];
 
       $position = (string)$params['postion'];
 
       $reportType = (int)$params['reportType'];
 
       $screenshotID = (string)$params['screenshotID'];
 
       $Summary = (string)$params['Summary'];
 
       $reporter = (string)$params['reporter'];

 
       $result $zsite->query("INSERT INTO reports VALUES (NULL, NOW(), '$regionName', '$abuserID', '$category', '$checkflags', '$details', '$objectID', '$position', '$reportType', '$screenshotID', '$Summary', '$reporter')");

 
       $response = array(
 
                       array(
 
                             'success'      => $result,
 
                             'errorMessage' => get_error_message($result),
 
               'struct'));
 
       return $this->xmlrpc->send_response($response);

 
   

The exact error this is giving me on the client end: Method reportuser, params System.Collections.Hashtable. Exception System.Xml.XmlException: Root element is missing.


I assume the implementation of xmlrpc within codeigniter is not standard and may block requests that are not properly formed or may be susceptible to xml injection and thus the request is failing, but I don't actually know. I also have no example of the request itself available due to the client being closed source. Can this be done using the bultin xmlrpc library or will I need to implement the xmlrpc server differently? Do I just have an error in the code perhaps?
Reply


Messages In This Thread
XMLRPC - Root element missing - by Tampa - 08-31-2018, 08:03 PM
RE: XMLRPC - Root element missing - by ciadmin - 08-31-2018, 09:24 PM
RE: XMLRPC - Root element missing - by Tampa - 09-02-2018, 09:45 PM
RE: XMLRPC - Root element missing - by ciadmin - 09-02-2018, 11:18 PM
RE: XMLRPC - Root element missing - by Tampa - 09-05-2018, 09:07 AM
RE: XMLRPC - Root element missing - by Tampa - 09-07-2018, 06:24 AM
RE: XMLRPC - Root element missing - by Tampa - 09-07-2018, 09:31 AM
RE: XMLRPC - Root element missing - by ciadmin - 09-07-2018, 10:01 AM
RE: XMLRPC - Root element missing - by Tampa - 09-07-2018, 01:39 PM



Theme © iAndrew 2016 - Forum software by © MyBB