Java Reference
In-Depth Information
4.
Luckily, Facebook also provides a “sandbox” where you can play around with their REST API
at https://developers.facebook.com/tools/explorer , which will automatically handle the
authentication for you. Now, execute a GET request on /me?fields=id,name,birthday . The
server responds with something similar to:
{
"id": "507162275",
"name": "Seppe Vanden Broucke",
"birthday": "11/09/1986"
}
5.
Note how you have supplied arguments with your request this time. You provided one fields
argument with content id,name,birthday to specify which fields you want to get back. This
way of passing arguments to REST requests is comparable to method‐argument passing in SOAP
or RMI.
accessing WeB services and sources With Java
Now that you know what web services are and how they work, it's high time you get to see how
you can access them using Java. This section discusses how to access three kinds of web services:
services offered over SOAP, RESTful web services, and web services that are, in fact, not offered as
a web service at all, using a technique called “screen scraping,” for when you really, absolutely want
to get some information out of a website.
accessing soap services
The first of the three kinds of web services discussed in this section is SOAP. This protocol was
introduced earlier in this chapter. Here you learn how to use it.
Installing JAX‐WS
JAX‐WS Java library will be used to access SOAP services. If you're using Eclipse with the Java JRE
(that is, you don't have the JDK installed), you'll need to perform the following steps to get JAX‐WS
running. If you're using the JDK, you're already up and running and can skip the installation steps
below.
1.
Browse to https://jax-ws.java.net and download the ZIP ile offered there (this topic
uses jaxws-ri-2.2.8.zip at the time of writing).
2.
This ZIP file contains a docs folder with documentation, a bin folder with some executables,
a samples folder containing code samples, and a lib folder with the actual library and sup-
port classes, stored in compressed Java Archives (or JAR) files. Extract the lib folder some-
where you can easily find it (e.g., on your desktop).
 
Search WWH ::




Custom Search