2 <head><title>xmlrpc - Getstatename demo</title></head>
4 <h1>Getstatename demo</h1>
6 <h2>Send a U.S. state number to the server and get back the state name</h2>
8 <h3>The code demonstrates usage of automatic encoding/decoding of php variables into xmlrpc values</h3>
11 include_once __DIR__ . "/../../src/Autoloader.php";
12 PhpXmlRpc\Autoloader::register();
14 if (isset($_POST["stateno"]) && $_POST["stateno"] != "") {
15 $stateNo = (integer)$_POST["stateno"];
16 $encoder = new PhpXmlRpc\Encoder();
17 $req = new PhpXmlRpc\Request('examples.getStateName',
18 array($encoder->encode($stateNo))
20 print "Sending the following request:<pre>\n\n" . htmlentities($req->serialize()) . "\n\n</pre>Debug info of server data follows...\n\n";
21 $client = new PhpXmlRpc\Client("http://phpxmlrpc.sourceforge.net/server.php");
23 $r = $client->send($req);
24 if (!$r->faultCode()) {
26 print "<br/>State number <b>" . $stateNo . "</b> is <b>"
27 . htmlspecialchars($encoder->decode($v)) . "</b><br/>";
29 print "An error occurred: ";
30 print "Code: " . htmlspecialchars($r->faultCode())
31 . " Reason: '" . htmlspecialchars($r->faultString()) . "'</pre><br/>";
37 print "<form action=\"getstatename.php\" method=\"POST\">
38 <input name=\"stateno\" value=\"" . $stateNo . "\"><input type=\"submit\" value=\"go\" name=\"submit\"></form>
39 <p>Enter a state number to query its name</p>";