Database Reference
In-Depth Information
Avoiding the service's Data Format Transformation using annotations
We have the Video Asset class exposed as a REST service. As you can see, we have
REST WADL describing how the same operation "Get Asset by Title from particular
Source" exposed through the Service Bus can be linked to two functions-wrappers with
different annotations: @Path and @Produces . Behind it we have the same getAs-
setList . This is about the GET method, but what about POST ? The annotation in this
case will be @Consumes and you can combine the json and xml formats in one an-
notation. Now, Client should include an appropriate content-type header in his POST
request to be properly handled. For more information about JAX-RS and JAXB, please
see the Oracle documentation at http://docs.oracle.com/javaee/6/tutorial/doc/gkknj.html .
In addition to that, Google supplied us with Gson to do simple serialization with JSON.
(We are using it currently in our projects at the moment of writing. Feel free to use Jack-
son instead. Don't forget to look at YQL from Yahoo REST API Console; it's very ingeni-
ous.) For a quick demonstration, let's just return to the media Search service we men-
tioned earlier and focus only on one external API from IMDb. The following REST API
will return JSON containing all records related to the Bourne Identity request.
Note
The search URL of the Bourne Identity request is http://www.imdb.com/xml/
find?json=1&nr=1&tt=on&q=Bourne%20Identity .
Casting it to the object will require just a couple of lines of code, shown as follows:
Search WWH ::




Custom Search