Problem with PHP Client/Server -> passing and returning an array

"Martin Walter" <[email protected]>
Newsgroups gmane.comp.php.xml-rpc
Message-ID <000501c2d769$9f953950$0300a8c0@captain>
Hello,
 
I am fairly new to the XML-RPC and ran into my first problem. At the
moment I am just testing some custom functions. One of my functions
receives and returns an array. When it run the script i get the
following error:
 
<b>Warning</b>:  htmlspecialchars() expects parameter 1 to be string,
array given in <b>/home/duracell/www/xmlrpc/includes/xmlrpc.inc</b> on
line <b>1204</b>
 
You could see the error on http://www.martinwalter.at/xmlrpc/array.php.
I am using xmlrpc-1.0.99.2 on Apache and PHP 4.2.3.
Please see my code below:
 
Client:
<?php
include('includes/xmlrpc.inc');
 
$client = new xmlrpc_client('/xmlrpc/server.php', 'www.martinwalter.at',
80);
$client -> setDebug(1);
 
$message = new xmlrpcmsg('examples.returnArray', array(new
xmlrpcval(array(new xmlrpcval(1, $xmlrpcInt), new xmlrpcval(2,
$xmlrpcInt), new xmlrpcval(3, $xmlrpcInt)), $xmlrpcArray)));
$result = $client -> send($message);
?>
 
Server:
<?php
include('includes/xmlrpc.inc');
include('includes/xmlrpcs.inc');
 
$errorCounter = 0;
$errorMessage = '';
 
$returnArray_sig = array(array($xmlrpcArray, $xmlrpcArray));
$returnArray_doc = 'Passes a given Array to the client.';
 
function returnArray($xmlrpcMessage)
{
            global $xmlrpcerruser;
            global $errorCounter, $errorMessage;
            
            $returnMessage = $xmlrpcMessage -> getParam(0);
            
            if ($returnMessage -> kindOf() != 'array')
            {
                        $errorMessage = 'Wrong argument type detected.
Required: Array';
                        $errorCounter++;
            }
            
            if ($errorCounter > 0)
            {
                        $response = new xmlrpcresp(0, $xmlrpcerruser,
$errorMessage);
            }
            else
            {
                        $elements = array();
                        
                        for ($i = 0; $i < $returnMessage -> arraysize();
$i++)
                        {
                                   $member = $returnMessage ->
arraymem($i);
                                   $value = $member -> scalarval();
                        
                                   $elements[] = new xmlrpcval($value,
$xmlrpcInt);
                        }
                        
                        $response = new xmlrpcresp(new
xmlrpcval($elements, $xmlrpcArray));
            }
            
            return $response;
}
 
$returnString_sig = array(array($xmlrpcString, $xmlrpcString));
$returnString_doc = 'Passes a given String to the client.';
 
$dispatchMap = array('examples.returnArray' => array('function' =>
'returnArray', 'signature' => $returnArray_sig, 'docstring' =>
$returnArray_doc));
$server = new xmlrpc_server($dispatchMap);
?>
 
I hope you have an idea how to get this fixed? Thanks in advance!
 
Best regards,
Martin Walter
 
mailto: [email protected]

_______________________________________________
phpxmlrpc mailing list
[email protected]
http://lists.usefulinc.com/cgi-bin/mailman/listinfo/phpxmlrpc
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.