Lesson 27

Consuming RESTful JSON Web Services

A web service is essentially a web application that runs on a web server and provides a list of methods that allow users to access server-side resources. These resources can be web pages, business data, images, or video files. You access the web service as you would any other website using a URL.

Web services themselves can be written using one of several technologies including Node.js, PHP, ASP.NET, and ColdFusion. Creating a web service is outside the scope of this book.

The examples in this lesson use a simple web service called MathService. Table 27.1 lists the operations supported by the web service, the web service end point, and a brief description of each.

Table 27.1 MathService Methods

Method Name Endpoint URL Supported HTTP Operations Description
CircleArea www.asmtechnology.com/MathService/CircleArea/?radius=X GET Input: radiusOutput: Returns the area of a circle with specified radius.
RectangleArea www.asmtechnology.com/MathService/RectangleArea/?length=X&breadth=Y GET Input: length, breadthOutput: Returns the area of a rectangle with specified length and breadth.
SquareArea www.asmtechnology.com/MathService/SquareArea/?length=X GET Input: lengthOutput: Returns the area of a square whose sides are of specified length.
TriangleArea www.asmtechnology.com/MathService/TriangleArea?base=X&height=Y GET Input: base, heightOutput: Returns the area of a triangle with specified base length and height.

Types of ...

Get Swift iOS 24-Hour Trainer 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.