Java Reference
In-Depth Information
Application: Using SSL, Atom Publishing, and the
Google Finance REST API
This is not a recipe but rather a complete application, as it addresses all at once a variety of
issues found in the real world of dealing with RESTful web services.
Years ago, Google used to publish SOAP-based APIs to let developers work with different
aspects of its platform. It has since deprecated those web services in favor of RESTful APIs.
You can interact with Google in lots of ways with REST, including interacting with Blogger,
Feedburner, AdSense, Calendar, CheckOut, Maps, OpenSocial, YouTube, Earth, Search, and
lots more. To see a complete list, visit http://code.google.com and click “APIs & Tools.”
In this application, you'll address several things at once:
▪ Interacting with a real-world RESTful web service that goes well beyond “Hello World.”
In this example, you'll use the Google Finance API to authenticate and get a user token,
create a new portfolio, and read the list of portfolios associated with an account.
▪ Working with the Atom Publishing Protocol, which has grown into a popular way to im-
plement REST.
▪ Using a secure socket to communicate over SSL with a RESTful service.
▪ Interacting with a RESTful service across multiple invocations in a “session.”
▪ Authenticating using raw HTTP.
▪ Working at a low level to establish connections at the socket layer in the absence of a
framework.
▪ Reading and writing data using GET and POST in REST.
▪ Dealing with some of the issues of working with services in the absence of WSDL.
It's a lot to cover, but this single example will encapsulate it all. One problem you confront in
dealing with RESTful services is that they do not present a WSDL. That means that you have
to negotiate the contract through some external means. In this example, you'll need to read the
documentation on the Google website to determine what the valid parameters are.
Before You Start
Running this example requires that you have a Google account set up. If you use Gmail or
another Google application that requires authentication, you're all set. Just use the username
and password associated with that account in these examples.
Search WWH ::




Custom Search