Home » Web Services » XML_RPC » Bug #4032
Failure to ret. XML_RPC_Response obj. in XML-RPC server results in fatal error
Details
| Request #4032 | Failure to ret. XML_RPC_Response obj. in XML-RPC server results in fatal error |
|---|---|
| Submitted | 2005-04-02 16:14 UTC |
| From | php at ceruleansky dot com |
| Assigned | danielc |
| Status | Closed |
| Package | XML_RPC |
| PHP Version | 5.0.2 |
| OS | Windows XP Home |
| Roadmaps | (Not assigned) |
Comments
[2005-04-02 16:14 UTC] php at ceruleansky dot com
Description:
------------
XML-RPC Version: 1.17
If you use the XML_RPC package for an XML-RPC server, and you fail to return an XML_RPC_Response object from a function found in the dispatch map, the following fatal error text is sent to the XML_RPC client, resulting in an XML parse error on the client side:
<br />
<b>Fatal error</b>: Call to a member function serialize() on a non-object in <b>c:\apachefriends\xampp\php\pear\XML\RPC\Server.php</b> on line <b>323</b><br />
It seems the code responsible for this fatal error is found in RPC/Server.php:
$payload = '<?xml version="1.0" encoding="'
. $this->encoding . '"?>' . "\n"
. $this->serializeDebug()
. $r->serialize();
It is the $r->serialize() part that is causing it.
Reproduce code:
---------------
<?php
require 'XML/RPC/Server.php'; // PEAR XML-RPC library
function echothis($xmlrpcdata)
{
$hellostr = XML_RPC_decode($xmlrpcdata->params[0]);
$hellostr = 'The text you submitted said was: ' . $hellostr;
$retval = XML_RPC_encode($hellostr);
// return new XML_RPC_Response($retval);
}
$dispatch_map = array( 'echoEcho' => array('function' => 'echothis') );
$server = new XML_RPC_Server($dispatch_map); // Start the server
?>
Client XML post:
<?xml version="1.0"?>
<methodCall>
<methodName>echoEcho</methodName>
<params>
<param><value><string>Please echo this text.</string></value></param>
</params>
</methodCall>
Expected result:
----------------
HTTP response by the server should have been an XML-RPC fault:
<methodResponse>
<fault>
<value>
<struct>
<member>
<name>faultCode</name>
<value><int>1000</int></value>
</member>
<member>
<name>faultString</name>
<value><string>XML-RPC Error: XML_RPC_Response object not returned by XML-RPC server.</string></value>
</member>
</struct>
</value>
</fault>
</methodResponse>
Actual result:
--------------
<br />
<b>Parse error</b>: syntax error, unexpected T_STRING in <b>C:\apachefriends\xampp\htdocs\mailingdb2\minimal_server.php</b> on line <b>14</b><br />
[2005-04-02 16:17 UTC] php at ceruleansky dot com
Oops:
I made an error in the part where I listed the actual result.
It should be:
<br />
<b>Fatal error</b>: Call to a member function serialize() on a non-object in <b>c:\apachefriends\xampp\php\pear\XML\RPC\Server.php</b> on line <b>323</b><br />