pear xmlrpc question
| From: | José Peso Echarri | Date: | Mon, 11 Dec 2006 16:43:54 +0000 |
| Subject: | pear xmlrpc question | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-245709@lists.php.net to get a copy of this message | ||
I have a simple helloWorld example in a xmlrpc version.
The xmlrpc implementation that i have used is the pear package XML_RPC 1.5.1.
The problem ocurrs when the server send back the response, i always receive the error "Invalid return payload:enable debuggin..".
With debug enabled the output is this:
---GOT---
HTTP/1.1 200 OK
Date: Mon, 11 Dec 2006 16:37:42 GMT
Server: JWS (Unix) PHP/4.4.4 mod_fastcgi/2.4.2
X-Powered-By: PHP/4.4.4
Content-Length: 538
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 (
'string' => 'Jose',
);
var $mytype = 1;
}
vvv POST DATA RECEIVED BY SERVER vvv
<?xml version="1.0" encoding="UTF-8"?>
<methodCall>
<methodName>helloWorld</methodName>
<params>
<param>
<value><string>Jose</string></value>
</param>
</params>
</methodCall>
^^^ END POST DATA ^^^
-->
<methodResponse>
<params>
<param>
<value><string>Hola Jose</string></value>
</param>
</params>
</methodResponse>
---END---
*Function Call:* helloWorld( Jose )
*Sent XML Message:*
<?xml version="1.0" encoding="UTF-8"?> <methodCall> <methodName>helloWorld</methodName> <params> <param> <value><string>Jose</string></value> </param> </params> </methodCall>
*Return Value:*
*Received XML Message:*
<methodResponse> <fault> <value> <struct> <member> <name>faultCode</name> <value><int>2</int></value> </member> <member> <name>faultString</name> <value><string>Invalid return payload: enable debugging to examine incoming payload</string></value> </member> </struct> </value> </fault> </methodResponse>
**************************
The client source code:
require_once("XML/RPC.php");
$nombre = "Jose";
$function = "helloWorld";
$p1 = new XML_RPC_Value($nombre, "string");
$params = array();
$params[] = $p1;
$message = new XML_RPC_Message($function, $params);
$client = new XML_RPC_Client("/pruebas/servicio.php", "www.wiloc.srv", 80);
$client->setDebug(true);
$result = $client->send($message);
echo "<p><b>Function Call:</b> $function( $nombre )</p>";
echo "<p><b>Sent XML Message:</b>";
echo "<pre>" . htmlentities($message->serialize()). "</pre></p>";
$value = $result->value();
echo "<p><b>Return Value:</b> $value </p>";
echo "<p><b>Received XML Message:</b>";
echo "<pre>" . htmlentities($result->serialize()) . "</pre></p>";
************************************
And the server source code:
**********************************
require_once("XML/RPC/Server.php");
$getnamelength_sig2 = array(array("string","string"));
$getnamelength_doc2 = "Hola mundo en xmlrpc";
function helloWorld($name)
{
$name1 = $name->getParam(0);
$result = new XML_RPC_Value("Hola ".$name1->getval(), "string");
return new XML_RPC_Response($result);
}
$map = array("helloWorld" =>
array("function" => "helloWorld",
"signature" => $getnamelength_sig2,
"docstring" => $getnamelength_doc2));
$server = new XML_RPC_Server($map,0,1);
$server->service();
What is wrong in this very simple example?
Thanks a lot,
Jose.