CodeIgniter Forums
XML RPC MYSQL WOES - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: XML RPC MYSQL WOES (/thread-13979.html)



XML RPC MYSQL WOES - El Forum - 12-14-2008

[eluser]NewToCodeIgnitor[/eluser]
I know similar question is answered earlier but my problem still exist. Please consider following test example.

ENV:
-----
PHP5, MYSQL5

Error from RPC CLIENT:
-----------------------
"The XML data receieved was either invalid or not in the correct form for XML-RPC. Turn on debugging to examine the XML data further."


Code Snippet on RPC Client
---------------------------
$request = array (array($articleId, 'int'),'struct');
$this->CI->xmlrpc->request($request);

if ( ! $this->CI->xmlrpc->send_request())
{
return $this->CI->xmlrpc->display_error();
}
else
{
return $this->CI->xmlrpc->display_response();
}


Code Snippet on RPC Server
--------------------------
$sqlQuery = 'select title, content from ARTICLE where articleId='.$articleId;
$query = $database->query($sqlQuery);
$responseArray = array();
foreach ($query->result_array() as $row)
{
array_push($responseArray, array($row,'struct'));
}
$response = array($responseArray,'struct');
return $this->xmlrpc->send_response($response);


Response on the browser
-----------------------
<?xml version="1.0" encoding="UTF-8"?>
<methodResponse>
<params>
<param>
<value>
<struct>
<member>
<name>0</name>
<value>
<struct>
<member>
<name>title</name>
<value>
<string>Test Article</string>
</value>
</member>
<member>
<name>content</name>
<value>
<string>TEST ARTICLE THIS IS</string>
</value>
</member>
</struct></value>
</member>
</struct></value>
</param>
</params>
</methodResponse>


No idea why RPC CLIENT is not considering above xml response from the RPC server as valid response.


XML RPC MYSQL WOES - El Forum - 12-14-2008

[eluser]NewToCodeIgnitor[/eluser]
Please attempt answering this question as well. its driving me nuts :-)


XML RPC MYSQL WOES - El Forum - 12-14-2008

[eluser]thinkigniter[/eluser]
Try this...
Code:
&lt;?php
      $sqlQuery = 'SELECT title, content FROM ARTICLE WHERE articleId='.$articleId;
      $query = $database->query($sqlQuery);
      //$responseArray = array();
      foreach ($query->result_array() as $row){
        $responseArray['struct'][] = $row;
      }
      //$response = array($responseArray,‘struct’);
      return $this->xmlrpc->send_response($responseArray, 'struct');
?&gt;



XML RPC MYSQL WOES - El Forum - 12-15-2008

[eluser]NewToCodeIgnitor[/eluser]
I tried and got following additional WARNING and the same error

Severity: Warning --&gt; htmlspecialchars() expects parameter 1 to be string, array given /var/www/html/example/system/libraries/Xmlrpc.php 1360
DEBUG - 2008-12-15 20:09:15 --&gt; Final output sent to browser
DEBUG - 2008-12-15 20:09:15 --&gt; Total execution time: 0.0590
DEBUG - 2008-12-15 20:09:15 --&gt; article_client send_request FAILED
DEBUG - 2008-12-15 20:09:15 --&gt; The XML data receieved was either invalid or not in the correct form for XML-RPC. Turn on debugging to examine the XML data further.


What could i be doing wrong. this seems to be very innocous code. is it anything to do with configuration or encoding issues?


XML RPC MYSQL WOES - El Forum - 12-15-2008

[eluser]Nick Husher[/eluser]
I'm going to guess and say that the CI client doesn't like it when struct names are numeric and not strings. Perhaps switching the outer struct to an array will solve your problem?