Hi-

I'm trying to get XML-RPC working with a simple set of example
applications.  First of all, I have a pretty stringent
environment set up, and I'm getting the following warnings:

Warning: Call-time pass-by-reference has been deprecated - in
/data2/home/httpd/rames/testing/xmlrpc/xmlrpc.inc on line 421

Warning: Call-time pass-by-reference has been deprecated - in
/data2/home/httpd/rames/testing/xmlrpc/xmlrpc.inc on line 424

...it's in the Socket->Connect( 'blah', &$errno, ... ) code, so
it shouldn't have too much effect if there were no socketing
errors.  However, I also have error_reporting set to E_ALL,
which causes the following error.
[ERROR] => Array
        (
                [Number] => 8
                [String] => Undefined index:  ac
                [File] => /data/home/httpd/rames/testing/xmlrpc/xmlrpc.inc
                [Line] => 333
        )
...Apparently a bugfix is to add the following lines just before
line 333:
        // replace characters that eval would
        // do special things with
+       if( !isset($_xh[$parser]['ac']) ) {
+               $_xh[$parser]['ac'] = '';
+       }
        $_xh[$parser]['ac'].=str_replace('$', '\$',
                str_replace('"', '\"', str_replace(chr(92),
                        $xmlrpc_backslash, $data)));
        }
...feel free to use this, I enter it into the public domain. ;^)

Finally, the real problem I'm having is that I get a response
code of:
        Fault: 1
        Reason: Unknown method
when performing the following calls:

[xmlrpc-server.php]
function doit( $params ) {
        ...
}
$server = new XMLRPC_SERVER(
                        array( 'test.doit' =>
                                array( "function", "doit" ),
                        )
                );

[xmlrpc-client.php]
$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
$result = $client->send( $request );


I've been working from the examples found at:
  http://php.weblogs.com/xml-rpc
which have been very helpful, but I'm stumped on this one.  I
can't make heads or tails of the function names within the code
(*_ee/_se/_sa, etc.), so it's difficult for me to track down
exactly where FAULT is being generated.

Attached is a complete copy of both scripts, any assistance or
LARTing would be helpful.  :^)

Thanks in advance!

--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! Sports - Coverage of the 2002 Olympic Games
http://sports.yahoo.com

--
For information about how to subscribe and unsubscribe from this list
visit http://xmlrpc.usefulinc.com/list.html

Reply via email to