2 <head><title>xmlrpc</title></head>
4 <h1>Webservice wrappper demo</h1>
5 <h2>Wrap methods exposed by server into php functions</h2>
6 <h3>The code demonstrates usage of the most automagic client usage possible:<br/>
7 1) client that returns php values instead of xmlrpcval objects<br/>
8 2) wrapping of remote methods into php functions
11 include("xmlrpc.inc");
12 include("xmlrpc_wrappers.inc");
14 $c = new xmlrpc_client("/server.php", "phpxmlrpc.sourceforge.net", 80);
15 $c->return_type = 'phpvals'; // let client give us back php values instead of xmlrpcvals
16 $r =& $c->send(new xmlrpcmsg('system.listMethods'));
19 echo "<p>Server methods list could not be retrieved: error '".htmlspecialchars($r->faultString())."'</p>\n";
24 echo "<p>Server methods list retrieved, now wrapping it up...</p>\n<ul>\n";
25 foreach($r->value() as $methodname) // $r->value is an array of strings
27 // do not wrap remote server system methods
28 if (strpos($methodname, 'system.') !== 0)
30 $funcname = wrap_xmlrpc_method($c, $methodname);
33 echo "<li>Remote server method ".htmlspecialchars($methodname)." wrapped into php function ".$funcname."</li>\n";
37 echo "<li>Remote server method ".htmlspecialchars($methodname)." could not be wrapped!</li>\n";
39 if($methodname == 'examples.getStateName')
41 $testcase = $funcname;
48 echo "Now testing function $testcase: remote method to convert U.S. state number into state name";
50 $statename = $testcase($statenum, 2);
51 echo "State number $statenum is ".htmlspecialchars($statename);