Web Services

Kenneth M. Anderson <kena@cs.colorado.edu>

Lecture 16: REST Example

Agenda

REST Example: Address Book

Step One: Configure Web Server

AddHandler cgi-script rb

<Directory "/Users/kena/Sites/cgi-bin">
    Options +ExecCGI
</Directory>

<Directory "/Users/kena/Sites/addressBook/data">
    Options +ExecCGI
    Script PUT /~kena/cgi-bin/put.rb
    Script DELETE /~kena/cgi-bin/delete.rb
    AllowOverride All
    <Limit GET POST PUT DELETE OPTIONS PROPFIND>
        Order allow,deny
        Allow from all
    </Limit>
    <LimitExcept GET POST PUT DELETE OPTIONS PROPFIND>
        Order deny,allow
        Deny from all
    </LimitExcept>
</Directory>
            

Step Two: Write CGI Scripts

  GET PUT DELETE POST
Groups command line tools either append groups.xml or members.xml to request based on the purpose of the GET; Apache handles this request creates a new group; updates the groups.xml file of the parent group removes the specified group; updates the groups.xml file of the parent group not used
Members retrieves the member's XML file; Apache handles this request creates a new member; updates the members.xml file of the specified group removes the specified member; updates the members.xml file of the specified group not used

Step 3: Write the command line scripts

Command Name Example Explanation
createGroup createGroup CU/CS Creates a group CS within the group CU
removeGroup removeGroup CU/CS Remove the group CS from the group CU
listGroups listGroups CU List the groups contained within the group CU; invoke command with no arguments to see top-level groups
addMember addMember CU Add a new member to the CU group; the addMember script asks you a series of questions to create the new member
removeMember removeMember CU Ken Anderson Remove the member Ken Anderson from the group CU
listMembers listMembers CU Retrieve the member names of the group CU
numMembers numMembers CU Print the number of members of the group CU
getMemberInfo getMemberInfo CU Ken Anderson Retrieve the XML file for Ken Anderson who is a member of the group CU and pretty print its information
getMemberIds getMemberIds CU For the group CU, map member names into member ids that can be used to construct the URI of a member resource

Discussion

Address Book, Take 2

Discussion of the Readings

Need Volunteers!

Class Project