Chapter 7. RPC and SOAP Services
In this chapter we’ll be looking at two closely-related types of services: Remote Procedure Call (RPC) services, and SOAP. These two feel fairly similar, as they both involve calling functions and passing parameters, but their implementations are in stark contrast as the RPC is a very loose way of describing a service, whereas SOAP is very tightly specified.
RPC
RPC services quite literally call procedures (i.e., functions) remotely. These types of API will typically have a single endpoint, so all requests are made to the same URL. Each request will include the name of the function to call, and may include some parameters to pass to it. Working with RPC services should feel familiar to us as developers because we know how to call functions—we simply do so over HTTP.
To start out, consider Example 6-2 when a call was made to Flickr. The URL we made for that example was:
http://api.flickr.com/services/rest/?method=flickr.photos.search&tags= kitten&format=xmlrpc
Within the URL, the name of the function can be seen in the “method” parameter (flickr.photos.search
), the particular tags to search for are found in tags=
, and the format
parameter asks for the response in XML-RPC format.
There is a distinct difference between using an RPC-style service, with function names and parameters included in the data supplied, and having a service that is true XML-RPC, which is a very defined format. The option you choose depends entirely on the situation you and your application ...
Get PHP Web Services now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.