One of those is the option to
interact with REST based web services provided by our own application server using Zend_Rest_Server.
Licensed to Menshu You
Zend Framework in Action (Ch01) Manning Publications Co. 32
11.4.1 Zend_Rest_Server
Let??™s imagine that we??™ve convinced one of the advertisers on Places; Edinburgh Zoo, to take part a joint
promotion that will be hosted separately from both of our sites. The idea is to make a short lifespan ???mash-up???
site based on content from Places, Edinburgh Zoo and other interested sites.
As we did with our XML-RPC server earlier we will start by making a simple interface to make sure our
server has a consistent API. Listing 11.13 shows our interface with two methods; one to get a place and one to
get the reviews for a place.
Listing 11.13 Our Places service application interface
interface Places_Service_Place_Interface
{
public function getPlace($id);
public function getReviews($id);
}
Next in listing 11.14 we make a concrete implement of our interface using queries similar to those from
our Zend_Db chapter. Note that the database results are returned as an array rather than the default objects
which would have failed when processed by Zend_Rest_Server. Another thing that you may notice is that
unlike Zend_XmlRpc_Server, Zend_Rest_Server does not require parameters and return values specified in
docblocks.
Pages:
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337