Representational State Transfer, from now on called REST, is actually not really a protocol, but merely a style of communication. Great advantages of having no protocol are simplicity, visibility and performance. A disadvantage is that the communication is not strictly defined, and therefore needs to be documented in a sufficient way. There is an attempt to standardize this communication, called Web Application Description Language (WADL), but it is not widely adopted.

Calling a REST service

Calling a REST service is done by URL. This means that all the information that the server needs, to process your request, is part of the URL (this is not entirely true due to HTTP headers, but close enough). Here is an example of a REST web service that allows you to receive live information on American airports:

https://soa.smext.faa.gov/asws/api/airport/status/IAD?format=xlm

Go ahead, click on it to see what the current conditions at Washington Dulles Airport are. Your answer may look something like this:

<AirportStatus>
    <Delay>false</Delay>
    <IATA>IAD</IATA>
    <State>District of Columbia</State>
    <Name>Washington Dulles International</Name>
    <Weather>
        <Visibility>10.00</Visibility>
        <Weather>Overcast</Weather>
        <Meta>
            <Credit>NOAA's National Weather Service</Credit>
            <Updated>4:52 AM Local</Updated>
            <Url>http://weather.gov/</Url>
        </Meta>
        <Temp>45.0 F (7.2 C)</Temp>
        <Wind>South at 4.6mph</Wind>
    </Weather>
    <ICAO>KIAD</ICAO>
    <City>Washington</City>
    <Status>
        <Reason>No known delays for this airport.</Reason>
        <ClosureBegin/>
        <EndTime/>
        <MinDelay/>
        <AvgDelay/>
        <MaxDelay/>
        <ClosureEnd/>
        <Trend/>
        <Type/>
    </Status>
</AirportStatus>

This answer is in XML format. The corresponding XSD (explained in 2. Simple Object Access Protocol (SOAP)) is hopefully placed in the documentation of the web service. If not, you will have to generate your own XSD on this answer and hope that it is correct. This is the largest drawback of REST services.

Now, lets look again at the URL:

https://soa.smext.faa.gov/asws/api/airport/status/IAD?format=xml

The URL consists of several elements:

  • The first part is the location of the webservice (https://soa.smext.faa.gov)
  • The next part is a fragment (/asws/api/airport/status/IAD). Fragments are used to supply information to the web service. This particular fragment indicates that you want to retrieve the airport status from the airport with code IAD. You can request information on a different airport by changing the URL, for example: https://soa.smext.faa.gov/asws/api/airport/status/JFK?format=xml.
  • Everything after the '?' are arguments. They essentially are also just information for your request. In this example the argument determines the answer format. It was set to XML in the example above.


  • No labels