Bug #7381 [NEW]: can not access a method within a class

From: Date: Wed, 12 Apr 2006 17:08:28 +0000
Subject: Bug #7381 [NEW]: can not access a method within a class
Groups: php.pear.doc 
Request: Send a blank email to pear-doc+get-7781@lists.php.net to get a copy of this message
From: stephane at cyberlogic dot ca Operating system: Linux Package version: PHP version: 4.4.2 Package: Documentation Bug Type: Bug Bug description: can not access a method within a class Description: ------------ XML_RPC 1.4.7 I try to access a method within a class by XML_RPC as shown on the example from the documentation but I get a response "Unknown method" from the server Test script: --------------- Server Side : <?php require_once 'XML/RPC/Server.php'; class some_class_name { function returnTimes2($params) { $param = $params->getParam(0); // This error checking syntax was added in Release 1.3.0 if (!XML_RPC_Value::isValue($param)) { return $param; } $val = new XML_RPC_Value($param->scalarval() * 3, 'int'); return new XML_RPC_Response($val); } } $some_object = new some_class_name; // Here are examples of the various ways to declare "functions": $server = new XML_RPC_Server( array('class_times2' =>array('function' => array('some_class_name' => 'returnTimes2'),),), array('class_times3' =>array('function' => 'some_class_name::returnTimes2'),) ); ?> Client Side : <?php require_once 'XML/RPC.php'; $input = 8; $params = array(new XML_RPC_Value($input, 'int')); //$msg = new XML_RPC_Message('class_times2', $params); $msg = new XML_RPC_Message('class_times3', $params); $cli = new XML_RPC_Client('/webServices/testServer.php', 'localhost'); $cli->setDebug(1); $resp = $cli->send($msg); if (!$resp) { echo 'Communication error: ' . $cli->errstr; exit; } if (!$resp->faultCode()) { $val = $resp->value(); echo $input . ' times 2 is ' . $val->scalarval(); } else { /* * Display problems that have been gracefully cought and * reported by the xmlrpc.php script. */ echo 'Fault Code: ' . $resp->faultCode() . "\n"; echo 'Fault Reason: ' . $resp->faultString() . "\n"; } ?> Expected result: ---------------- ---GOT--- HTTP/1.1 200 OK Date: Wed, 12 Apr 2006 17:06:06 GMT Server: Apache X-Powered-By: PHP/4.4.2-gentoo Content-Length: 515 Connection: close Content-Type: text/xml; charset=UTF-8 <?xml version="1.0" encoding="UTF-8"?> <!-- PEAR XML_RPC SERVER DEBUG INFO: 0 - class xml_rpc_value { var $me = array ( 'int' => '8', ); var $mytype = 1; } vvv POST DATA RECEIVED BY SERVER vvv <?xml version="1.0" encoding="UTF-8"?> <methodCall> <methodName>class_times2</methodName> <params> <param> <value><int>8</int></value> </param> </params> </methodCall> ^^^ END POST DATA ^^^ --> <methodResponse> <params> <param> <value><int>16</int></value> </param> </params> </methodResponse> ---END--- ---PARSED--- object(xml_rpc_value)(2) { ["me"]=> array(1) { ["int"]=> string(2) "16" } ["mytype"]=> int(1) } ---END--- 8 times 2 is 16 Actual result: -------------- ---GOT--- HTTP/1.1 200 OK Date: Wed, 12 Apr 2006 17:04:33 GMT Server: Apache X-Powered-By: PHP/4.4.2-gentoo Content-Length: 729 Connection: close Content-Type: text/xml; charset=UTF-8 <?xml version="1.0" encoding="UTF-8"?> <!-- PEAR XML_RPC SERVER DEBUG INFO: 0 - class xml_rpc_value { var $me = array ( 'int' => '8', ); var $mytype = 1; } vvv POST DATA RECEIVED BY SERVER vvv <?xml version="1.0" encoding="UTF-8"?> <methodCall> <methodName>class_times3</methodName> <params> <param> <value><int>8</int></value> </param> </params> </methodCall> ^^^ END POST DATA ^^^ --> <methodResponse> <fault> <value> <struct> <member> <name>faultCode</name> <value><int>1</int></value> </member> <member> <name>faultString</name> <value><string>Unknown method</string></value> </member> </struct> </value> </fault> </methodResponse> ---END--- ---PARSED--- object(xml_rpc_value)(2) { ["me"]=> array(1) { ["struct"]=> array(2) { ["faultCode"]=> object(xml_rpc_value)(2) { ["me"]=> array(1) { ["int"]=> string(1) "1" } ["mytype"]=> int(1) } ["faultString"]=> object(xml_rpc_value)(2) { ["me"]=> array(1) { ["string"]=> string(14) "Unknown method" } ["mytype"]=> int(1) } } } ["mytype"]=> int(3) } ---END--- Fault Code: 1 Fault Reason: Unknown method -- Edit bug report at http://pear.php.net/bugs/bug.php?id=7381&edit=1 --

« previous php.pear.doc (#7781) next »