Welcome Guest, Not a member yet? Register   Sign In
XML RPC MYSQL WOES
#1

[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.
#2

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

[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;
#4

[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?
#5

[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?




Theme © iAndrew 2016 - Forum software by © MyBB