INFO-H511: Web Services

Presenter Notes

Organisation

Teaching-Assistant:

Francois Picalausa (fpicalau@ulb.ac.be)

5 labs:

  1. HTTP Programming
  2. Developing REST Services
  3. Using & Developing SOAP Services
  4. Composite Services
  5. Presenting Web Services

Presenter Notes

Goals

  1. Gaining practical knowledge of the Web Services concepts, and
  2. Bootstrapping your project

You are free to choose your tools to solve the exercises.

However, code skeletons and solutions are currently only provided in Java.

Presenter Notes

Lab 1: HTTP Programming

Presenter Notes

Schedule of This lab

14:10 — 14:40
  • Introduction to HTTP
  • Exercises 1.1 and 1.2
14:50 — 16:00
  • Exercise 2.1: Yahoo and Bing Maps
  • Exercise 2.2: Google Documents API

Presenter Notes

Part 1: Manually Querying the Web

Presenter Notes

Dissecting an HTTP request

GET rfc5023 HTTP/1.1⏎
Host: tools.ietf.org⏎
User-Agent: Mozilla/5.0 (Windows ...⏎
Accept: text/html,...;q=0.9,*/*;q=0.8⏎
Accept-Language: en-us,en;q=0.5⏎
Accept-Encoding: gzip, deflate⏎
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7⏎
Connection: keep-alive⏎
If-Modified-Since: Mon, 09 Jan 2012 22:47:46 GMT⏎
If-None-Match: "1827ba7-21df5-4b6202feb4880;4b6ff84c9e6cf"⏎
Cache-Control: max-age=0⏎
⏎

Presenter Notes

Dissecting an HTTP Response

HTTP/1.1 200 OK
Date: Fri, 27 Jan 2012 00:46:12 GMT⏎
Server: Apache/2.2.21 (Debian)⏎
Content-Location: rfc5023.html⏎
Last-Modified: Mon, 09 Jan 2012 22:47:46 GMT⏎
Etag: "1827ba7-21df5-4b6202feb4880;4b777cde1187e"⏎
Accept-Ranges: bytes⏎
Content-Encoding: gzip⏎
Content-Length: 29741⏎
Keep-Alive: timeout=5, max=100⏎
Connection: Keep-Alive⏎
Content-Type: text/html; charset=latin-1⏎
⏎
<!DOCTYPE html PUBLIC "-//W3C//DTD
...

Presenter Notes

Sending Requests

Many tools can be used to send HTTP requests: firefox, curl, wget...

In this first part, we will use curl:

curl -v -X <Method> -H "<header>: <value>" http://...

Presenter Notes

Questions

Presenter Notes

Part 2: Programatically Querying the Web

Presenter Notes

Exercise 1: Maps with Yahoo! and Bing

We will implement a tool to fetch maps of given places

java MyMapTool "Atomium" /tmp/map.png

Presenter Notes

Querying RPC-Style services

Yahoo! PlaceFinder and Bing Map Imagery are RPC-style services.

The APIs provide (cf. documentation):

  1. the URI where a method is available
  2. the corresponding HTTP method and headers,
  3. the format of the response

Presenter Notes

Requests with Jersey

String url = "http://www.example.org/map?place=Atomium";

Client client = new Client();

// GET the url
ClientResponse response =
    client.resource(url).get(ClientResponse.class);

//Get the data
InputStream data = response.getEntityStream();

Presenter Notes

Command line arguments in Eclipse

assets/menu.png

Presenter Notes

Command line arguments in Eclipse

assets/runconfig.png

Presenter Notes

Exercise 2: Google Documents API

Google Documents can be accessed via a REST-style API.

In this API

  • Data are AtomPub documents
  • Links between these documents allow to discover new interactions for the applicati

Various libraries provide native access to this API. We will get insights on how these libraries use the REST API.

Presenter Notes

Exercise 2: AtomPub

assets/doc.png

Presenter Notes

Exercise 2: Documents List API

assets/doc-goog.png

Presenter Notes

Exercise 2: Documents List API (2)

assets/doc-spread.png

Presenter Notes

Exercise 2: Documents Feed

<feed xmlns="http://www.w3.org/2005/Atom" [...]>
  <id>https://[...]/full</id>
  <updated>2009-08-17T11:10:16.894Z</updated>
  <title>Available Documents - john.smith.example@gmail.com</title>

  <author>
    <name>John Smith</name>
    <email>john.smith.example@gmail.com</email>
  </author>

Presenter Notes

Exercise 2: Documents Feed

<link rel="alternate" type="text/html"
  href="https://docs.google.com"/>
<link rel="http://[...]#resumable-create-media" type="application/atom+xml"
  href="https://[...]/create-session/default/private/full"/>
<link rel="self" type="application/atom+xml"
  href="https://[...]/full/"/>
<link rel="http://[...]/g/2005#post" type="application/atom+xml"
    href="https://[...]/full"/>
<link rel="http://[...]/g/2005#batch" type="application/atom+xml"
    href="https://[...]/full/batch"/>

Presenter Notes

Exercise 2: Documents Feed

<entry xmlns:gd="http://[...]/g/2005" gd:etag="'HhJSFgpeRyt7ImBq'">
  <id>https://docs.google.com/feeds/id/pdf%3A12345</id>
  <published>2009-04-09T18:23:09.035Z</published>
  <category scheme="http://[...]/g/2005/labels"
    term="http://[...]/g/2005/labels#starred" label="starred"/>
  <category scheme="http://[...]/g/2005#kind"
    term="http://schemas.google.com/docs/2007#pdf" label="pdf"/>
  <title>PDF's Title</title>

  <content type="application/pdf" src="..."/>

Presenter Notes

Exercise 2: Documents Feed

  <link rel="alternate" type="text/html"
    href="https://docs.google.com/fileview?id=12345&amp;hl=en"/>
  <link rel="self" type="application/atom+xml"
    href="https://[...]/full/pdf%3A12345"/>
  <link rel="edit" type="application/atom+xml"
    href="https://[...]/full/pdf%3A12345"/>
  <link rel="edit-media" type="application/pdf"
    href="https://docs.google.com/feeds/default/media/pdf%3A12345"/>
  <gd:resourceId>pdf:12345</gd:resourceId>
  <docs:writersCanInvite value="false"/>
</entry> <entry> ... </entry> </feed>

Presenter Notes

Code Skeleton

OAuth authorization
The application will provide you with a link on which you can authorize the application.
AtomResourceDescription
This class parses Atom feeds and entries.
AtomDocument
This class helps building Atom entries.

The solution is online. If you are stuck, feel free to have a look at it!

Presenter Notes

Authorization

Bing & Google requires an application key:

  • Download the key on the labs website.
  • Copy paste it in the code skeleton.

This key will be disabled after the lab. You can create one for yourself after that.

You also need a Google account to access Google Documents.

Presenter Notes

Questions

Presenter Notes