Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

Chapter 5. Integrating Web Applications:... > Understanding the Client Classes

5.2. Understanding the Client Classes

Before going deeply into the details of the PHP XML-RPC implementation, let's look at a short example that gives a good idea of what a simple client XML-RPC method invocation looks like. Example 5-1 shows an invocation of the method examples.getStateName that takes an int value and returns a string that contains the name of the corresponding U.S. state.

Example 5-1. Using UserLand's state name server

include("xmlrpc.inc");

$thestate=32;

$c=new xmlrpc_client("/RPC2", "betty.userland.com", 80);
$f=new xmlrpcmsg('examples.getStateName',
                 array(new xmlrpcval($thestate, "int")));
$r=$c->send($f);
$v=$r->value(  );

if (!$r->faultCode(  )) {
    print "State number ". $thestate . " is " .
          $v->scalarval(  ) . "<br />";
          print "<hr />I got this value back<br /><pre>" .
          htmlentities($r->serialize(  )). "</pre><hr />\n";
} else {
    print "Fault: ";
    print "Code: " . $r->faultCode(  ) . 
    " Reason '" .$r->faultString(  )."'<br />";
}


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial