Agesort demo

Send an array of 'name' => 'age' pairs to the server that will send it back sorted.

The source code demonstrates basic lib usage, including handling of xmlrpc arrays and structs

You can see the source to this page here: agesort.php

24, "Edd" => 45, "Joe" => 37, "Fred" => 27); print "This is the input data:
";
foreach ($inAr as $key => $val) {
    print $key . ", " . $val . "\n";
}
print "
"; // Create parameters from the input array: an xmlrpc array of xmlrpc structs $p = array(); foreach ($inAr as $key => $val) { $p[] = new PhpXmlRpc\Value( array( "name" => new PhpXmlRpc\Value($key), "age" => new PhpXmlRpc\Value($val, "int") ), "struct" ); } $v = new PhpXmlRpc\Value($p, "array"); print "Encoded into xmlrpc format it looks like this:
\n" . htmlentities($v->serialize()) . "
\n"; // create client and message objects $req = new PhpXmlRpc\Request('examples.sortByAge', array($v)); $client = new PhpXmlRpc\Client(XMLRPCSERVER); // set maximum debug level, to have the complete communication printed to screen $client->setDebug(2); // send request print "Now sending request (detailed debug info follows)"; $resp = $client->send($req); // check response for errors, and take appropriate action if (!$resp->faultCode()) { print "The server gave me these results:
";
    $value = $resp->value();
    foreach ($value as $struct) {
        $name = $struct["name"];
        $age = $struct["age"];
        print htmlspecialchars($name->scalarval()) . ", " . htmlspecialchars($age->scalarval()) . "\n";
    }

    print "
For nerds: I got this value back
" .
        htmlentities($resp->serialize()) . "

\n"; } else { print "An error occurred:
";
    print "Code: " . htmlspecialchars($resp->faultCode()) .
        "\nReason: '" . htmlspecialchars($resp->faultString()) . '\'

'; } ?>