2 <head><title>xmlrpc</title></head>
4 <h1>Introspect demo</h1>
5 <h2>Query server for available methods and their description</h2>
6 <h3>The code demonstrates usage of multicall and introspection methods</h3>
9 function display_error($r)
11 print "An error occurred: ";
12 print "Code: " . $r->faultCode()
13 . " Reason: '" . $r->faultString() . "'<br/>";
15 // 'new style' client constructor
16 $c = new xmlrpc_client("http://phpxmlrpc.sourceforge.net/server.php");
17 print "<h3>methods available at http://" . $c->server . $c->path . "</h3>\n";
18 $m = new xmlrpcmsg('system.listMethods');
20 if ($r->faultCode()) {
24 for ($i = 0; $i < $v->arraysize(); $i++) {
25 $mname = $v->arraymem($i);
26 print "<h4>" . $mname->scalarval() . "</h4>\n";
27 // build messages first, add params later
28 $m1 = new xmlrpcmsg('system.methodHelp');
29 $m2 = new xmlrpcmsg('system.methodSignature');
30 $val = new xmlrpcval($mname->scalarval(), "string");
33 // send multiple messages in one pass.
34 // If server does not support multicall, client will fall back to 2 separate calls
35 $ms = array($m1, $m2);
37 if ($rs[0]->faultCode()) {
38 display_error($rs[0]);
40 $val = $rs[0]->value();
41 $txt = $val->scalarval();
43 print "<h4>Documentation</h4><p>${txt}</p>\n";
45 print "<p>No documentation available.</p>\n";
48 if ($rs[1]->faultCode()) {
49 display_error($rs[1]);
51 print "<h4>Signature</h4><p>\n";
52 $val = $rs[1]->value();
53 if ($val->kindOf() == "array") {
54 for ($j = 0; $j < $val->arraysize(); $j++) {
55 $x = $val->arraymem($j);
56 $ret = $x->arraymem(0);
57 print "<code>" . $ret->scalarval() . " "
58 . $mname->scalarval() . "(";
59 if ($x->arraysize() > 1) {
60 for ($k = 1; $k < $x->arraysize(); $k++) {
61 $y = $x->arraymem($k);
62 print $y->scalarval();
63 if ($k < $x->arraysize() - 1) {
68 print ")</code><br/>\n";
71 print "Signature unknown\n";