O'Reilly logo

PHP Web Services by Lorna Jane Mitchell

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 9. RPC and SOAP Services

In this chapter we’ll talk about two closely-related types of service: RPC (Remote Procedure Call) services, and SOAP. These two feel fairly similar to use as they involved calling functions and passing parameters, but their implementations are a 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 feels familiar to us as developers because we know how to call functions, and we simply do so over HTTP.

As a quick example, let’s revisit the call we made to flickr earlier (see Fetching data from Flickr’s XMLRPC service). 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, you can see the name of the function in the “method” parameter flickr.photos.search, and the additional fields we pass in; tags to search for a particular tag and a format parameter to ask for the response in XML-RPC format.

There is a distinct difference between using an RPC-style service, with function names and parameters as part of the data we pass, and having a service that is true XML-RPC[14], which is a very defined format. Which ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required