XML and PHP [Electronic resources]

Vikram Vaswani

نسخه متنی -صفحه : 84/ 52
نمايش فراداده

Chapter 6. PHP and XML-Based Remote Procedure Calls (RPC)

"Any sufficiently advanced technology is indistinguishable from magic."

Arthur C. Clarke

It's quite likely, if you're coming at this from a non-C/C++ background, that you've never heard of Remote Procedure Calls (RPC). This is a shame, because not only has RPC been around for a while, it's also a fairly interesting idea that opens the door to a whole new generation of cutting-edge, network-based services.

Stripped down to its bare bones, RPC defines a client-server framework for distributed computing, allowing procedures on a server to be remotely executed by a client. The existing network layer is used for communication between the client and server; this implies that the client invoking the procedure may be on either the same physical machine or a completely different machine on the network (hence the term remote procedure call).

Now, the Internet is the biggest, baddest network of them all; and when it comes to implementing RPC over the web, it makes sense to use HTTP as the transport layer and XML as the encoding toolkit. All that's required is a formal specification to handle the nitty-gritty details: the format of RPC requests and responses, data types, error handling, and so on. And so we have XML-RPC, a specification for encoding remote procedure calls in XML; and Simple Object Access Protocol (SOAP), an emerging W3C standard for encoding and packaging data for distribution across a peer-to-peer network. Both are XML-based technologies, both are fairly simple to use, and both are supported in PHP 4.1.0.

In the preceding chapter, you saw how potent the XML/PHP combination can be, and how much it simplifies information exchange over the web. This chapter takes things a step further by examining, through examples and code listings, how PHP's implementation of XML-based RPC can be used to enable new types of distributed, web-based applications and services.