12.7.3. Discussion
XML-RPC, a format created by Userland Software, allows you to make a
request to a web server using HTTP. The request itself is a specially
formatted XML document. As a client, you build up an XML request to
send that fits with the XML-RPC specification. You then send it to
the server, and the server replies with an XML document. You then
parse the XML to find the results. In the Solution, the XML-RPC
server returns a state name, so the code prints:
I love New York!
Unlike earlier implementations of XML-RPC, which were coded in PHP,
the current bundled extension is written in C, so there is a
significant speed increase in processing time. To enable this
extension while configuring PHP, add
--with-xmlrpc.
The server settings tell PHP which web site to contact to make the
request. The $host is the hostname of the machine;
$port is the port the web server is running on,
which is usually port 80; and $uri is the pathname
to the XML-RPC server you wish to contact. This request is equivalent
to http://betty.userland.com:80/RPC2. If no port
is given, the function defaults to port 80, and the default URI is
the web server root, /.