Getting started with REST implementation

We are now familiar with REST API and JSON. Plus, we also know that REST API is indeed useful in many different ways. Let us now try to put it into practice.

Passing commands in SOAP versus REST

Say, we need to query a given database for user details of a user with ID 1191. Using web services and Simple Object Access Protocol (SOAP), we will be doing something such as the following:

<?xml version="1.1"?> 
<soap:Envelope 
xmlns:soap="http://www.w3.org/2001/12/soap-envelope" 
soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding"> 
<soap:body pb="http://www.example.com/database"> 
<pb:GetUserDetails> 
<pb:UserID>1191</pb:UserID> 
</pb:GetUserDetails> 
</soap:Body> 
</soap:Envelope> 

The preceding code will give ...

Get Learning WordPress REST API 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.