Developers can use a variety of programming languages and approaches to implement web services. One of the most common approaches is to create a RESTful service. The REST in RESTful service stands for Representational State Transfer, which defines how an application must interact with the services. Developers can create RESTful services using any programming language. The following PHP script, Uppercase.php, converts the parameter it receives to uppercase characters:
The script’s processing is straightforward. As you can see, the script uses the PHP $_GET function to retrieve the name passed to the script as a query-string parameter and then uses the strtoupper function to convert the name to uppercase. The script then returns the status value 200 to indicate success.
Developers can call RESTful services from most programming languages. The following Upper.HTML, uses JavaScript to call the RESTful service:
The JavaScript code uses AJAX (asynchronous JavaScript) to call the Uppercase.php restful API, passing to name to convert to uppercase as a query-string parameter. When the API completes, it “call back” the function specified returning the ready-state value 4 and the status value 200 to indicate success.
3.149.240.75