[eluser]kalpesh[/eluser]
Hi,
I am new in Codeigniter.
I really like this framework.
Its simple in document and use.
I am trying to create web service with xml-rpc.
In response of xml-rpc i get two errors on xmlrpc library at line 1360 and my server class at line 22 .
I dont get why this error has occured.
Code:
---DATA---
HTTP/1.1 200 OK
Date: Mon, 16 Mar 2009 14:14:14 GMT
Server: Apache/2.2.3 (Win32) PHP/5.2.0
X-Powered-By: PHP/5.2.6
Content-Length: 1545
Connection: close
Content-Type: text/xml
<div style="border:1px solid #990000;padding-left:20px;margin:0 0 10px 0;">
<h4>A PHP Error was encountered</h4>
<p>Severity: Notice</p>
<p>Message: Undefined index: 0</p>
<p>Filename: controllers/mycontroller.php</p>
<p>Line Number: 22</p>
</div><div style="border:1px solid #990000;padding-left:20px;margin:0 0 10px 0;">
<h4>A PHP Error was encountered</h4>
<p>Severity: Notice</p>
<p>Message: Undefined index: 1</p>
<p>Filename: controllers/mycontroller.php</p>
<p>Line Number: 23</p>
</div><div style="border:1px solid #990000;padding-left:20px;margin:0 0 10px 0;">
<h4>A PHP Error was encountered</h4>
<p>Severity: Warning</p>
<p>Message: htmlspecialchars() expects parameter 1 to be string, array given</p>
<p>Filename: libraries/Xmlrpc.php</p>
<p>Line Number: 1360</p>
</div><div style="border:1px solid #990000;padding-left:20px;margin:0 0 10px 0;">
<h4>A PHP Error was encountered</h4>
<p>Severity: Warning</p>
<p>Message: htmlspecialchars() expects parameter 1 to be string, array given</p>
<p>Filename: libraries/Xmlrpc.php</p>
<p>Line Number: 1360</p>
</div><?xml version="1.0" encoding="UTF-8"?>
<methodResponse>
<params>
<param>
<value>
<struct>
<member>
<name>function</name>
<value>
<string></string>
</value>
</member>
<member>
<name>table</name>
<value>
<string></string>
</value>
</member>
<member>
<name>Pro_Id</name>
<value>
<string>242</string>
</value>
</member>
<member>
<name>Pro_Name</name>
<value>
<string>Ferrari</string>
</value>
</member>
</struct></value>
</param>
</params>
</methodResponse>
---END DATA---
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.
And My server class is mycontroller.php
Code:
class mycontroller extends Controller {
function mycontroller()
{
parent::Controller();
$this->load->library('xmlrpc');
$this->load->library('xmlrpcs');
}
function index()
{
$config['functions']['call'] = array('function' => 'mycontroller.myfunction');
$config['functions']['call2'] = array('function' => 'mycontroller.myfunction2');
$this->xmlrpcs->initialize($config);
$this->xmlrpcs->serve();
}
function myfunction($request)
{
$this->load->database();
$parameters = $request->output_parameters();
$function = $parameters['0'];
$table = $parameters['1'];
if ($this->db->get('product'))
{
$query=$this->db->get('product');
foreach ($query->result() as $row)
{
$content= $row->Pro_Id;
$content1= $row->CarName;
}
}
else
{
$content = 'failure';
}
$response = array(
array(
'function' => array($function, 'string'),
'table' => array($table, 'string'),
'Pro_Id' => array($content, 'string'),
'CarName' => array($content1, 'string'),
),
'struct');
return $this->xmlrpc->send_response($response);
}
}
Please help me .
Thanks in advance.