Page 345 - Open Soource Technologies 304.indd
P. 345
Unit 13: Extensible Markup Language
user_data parameter was. Notes
The options parameter to xmlrpc_server_call_method( ) is an array mapping option names to
their values. The options are:
output_type
Controls the data encoding used. Permissible values are: “php” or “xml” (default).
verbosity
Controls how much whitespace is added to the output XML to make it readable to
humans. Permissible values are: “no_white_space”, “newlines_only”, and “pretty”
(default).
escaping
Controls which characters are escaped, and how. Multiple values may be given as a
subarray. Permissible values are: “cdata”, “non-ascii” (default), “non-print” (default), and
“markup” (default).
versioning
Controls which web service system to use. Permissible values are: “simple”, “soap 1.1”,
“xmlrpc” (default for clients), and “auto” (default for servers, meaning “whatever format
the request came in”).
encoding
Controls the character encoding of the data. Permissible values include any valid encoding
identifiers, but you will rarely want to change it from “iso-8859-1” (the default).
Develop a PHP program to make a DTD for a text file.
13.6.2 Clients
An XML-RPC client issues an HTTP request and parses the response. The xmlrpc extension that
ships with PHP can work with the XML that encodes an XML-RPC request, but it does not know
how to issue HTTP requests. For that functionality, this file contains a function to perform the
HTTP request. The example shows a client for the multiply XML-RPC service.
Basic XML-RPC client
<?
php require_once(‘utils.php’);
$options = array(‘output_type’ => ‘xml’, ‘version’ => ‘xmlrpc’);
$result = xu_rpc_http_concise( array(method => ‘multiply’, args => array(5, 6), host =>
‘192.166.0.1’, uri => ‘/~gnat/test/ch11/xmlrpc-server.php’, options => $options));
echo “5 * 6 is $result”;
?>
We begin by loading the XML-RPC convenience utilities library. This gives us the xu_rpc_http_
concise( ) function, which constructs a POST request for us:
$response = xu_rpc_http_concise(hash);
LOVELY PROFESSIONAL UNIVERSITY 339