[phpxmlrpc] Perl Client, PHP Server, passing arrays or hashes
Jeff Bearer
jbearer@pittsburghlive.com
28 Nov 2002 11:27:57 -0500
Hello,
I'm attempting to pass a hash or an array from a perl client to a php
server, and I can't get it to work, I keep getting the error:
> Fault returned from XML RPC Server, fault code 3:
> Incorrect parameters passed to method: Wanted , got at param )
I'm using the Frontier-rpc Perl module, I'm pretty sure that I have the
method signature correct, I can change it to pass strings and it works,
but if I try to pass arrays or hashes I get errors.
I don't know what I'm doing wrong, if somebody could point it out that
would be great. Here are my two files:
--Client------------------------------------------------------
#!/usr/bin/perl
use Frontier::Client;
# Make an object to represent the XML-RPC server.
$server_url = 'http://localhost/rpcd.php';
$server = Frontier::Client->new(url => $server_url);
#%test = ( name => 'bob', age => '15' );
@test = ( 'one','two','three','four');
#$test = "yoyoyo";
# Call the remote server and get our result.
$result = $server->call('aptnet.register_client', @test);
print $result->{'output'} ."\n";
--Server------------------------------------------------------
<?php
include_once "xmlrpc/xmlrpc.inc";
include_once "xmlrpc/xmlrpcs.inc";
function register_client($params){
// Get the structure of values passed
$ve=var_export($params,true);
// Build our response.
$struct = array('output' => new xmlrpcval($ve));
return new xmlrpcresp(new xmlrpcval($struct, $xmlrpcStruct));
}
$register_client_sig=array(array($xmlrpcStruct,$xmlrpcArray));
$register_client_doc='Registration Function';
$s=new xmlrpc_server( array(
"aptnet.register_client" => array(
"function" => "register_client",
"signature" => $register_client_sig,
"docstring" => $register_client_doc
)
));
?>
--------------------------------------------------------------
--
Jeff Bearer, RHCE
Webmaster, PittsburghLIVE.com
Winner 2002 Eppy Award, Best U.S. Newspaper Website