Hi all (all two people? ;^)
I'm still having problems with the following code, as far as I
can tell, I've got the server set up properly: with a function
named doit, and a reference from "test.doit" => "function,
doit", but the client is receiving the "Unknown function"
response when it requests the test.doit method
<name>faultString</name>
<value><string>Unknown method</string></value>
I'm still guessing it's something simple that I'm missing, but I
still can't see it for myself. Any pointers would be
appreciated!
--Robert
[xmlrpc-server.php]
<?php
include_once('xmlrpc/xmlrpc.inc');
include_once('xmlrpc/xmlrpcs.inc');
function doit( $params )
{
$name = $params->getParam( 0 );
$company = $params->getParam( 1 );
$blah = "The person $name works at $company, cool!";
$response = new XMLRPCRESP(
new XMLRPCVAL( $blah, "string" )
);
return( $response );
}
$server = new XMLRPC_SERVER(
array( 'test.doit' =>
array( "function", "doit" ),
)
);
?>
[xmlrpc-client.php]
<?php
include_once('xmlrpc/xmlrpc.inc');
// setup queries
$username = 'Robert Ames';
$company = 'Consolidated Amalgamation, Inc.';
// generate request object
$request = new XMLRPCMSG('test.doit',
array(
new XMLRPCVAL($username,
'string'),
new XMLRPCVAL($company,
'string'),
)
);
// make connection to foreign server
$client = new XMLRPC_CLIENT( '/testing/xmlrpc-server.php',
'rames.int', 80 );
$client->setDebug( TRUE );
// send the request
/* ** DEBUGGING INFORMATION ** */
echo "<div style='background:pink' align=left><pre>";
print_r( $request );
echo "</pre></div>";
$result = $client->send( $request );
// see what we got back
if( $result->faultCode() )
{
// error occured
echo "<br>Fault: " . $result->faultCode();
echo "<br>Reason: " . $result->faultString();
}
else
{
// no error, got a result
$value = $result->value();
/* ** DEBUGGING INFORMATION ** */
echo "<div style='background:white' align=left><pre>";
echo "<b>Result:</b><br>";
print_r( $value );
echo "</pre></div>";
}
?>
__________________________________________________
Do You Yahoo!?
Yahoo! Greetings - Send FREE e-cards for every occasion!
http://greetings.yahoo.com
--
For information about how to subscribe and unsubscribe from this list
visit http://xmlrpc.usefulinc.com/list.html