This chapter covers building web services. If you’re unfamiliar with the fundamental concepts of web services, including REST, SOAP, and XML-RPC, jump back a chapter and read through Chapter 14. It provides the building blocks for the web services servers described here.
Recipe 15.1 covers building a REST method. With a REST server, you accept an HTTP request, process the incoming data, and reply, usually with XML.
The SOAP portion concludes with a discussion on how to combine authentication with SOAP in Recipe 15.8.
The chapter concludes with a Recipe 15.9, a recipe on serving XML-RPC requests.
You want to expose a server via REST. This allows people to make HTTP requests and receive XML in response.
The most basic REST server is a page that accepts query arguments and returns XML:
<?php // data $music_database = <<<_MUSIC_ <?xml version="1.0" encoding="utf-8" ?> <music> <album id="1"> <name>Revolver</name> <artist>The Beatles</artist> </album> <!-- 941 more albums ...