This example demonstrates how to use JSON representation of JAXB based resources.
A simple web application is presented with just one resource: flight list. A client can obtain the list or update it using XML or JSON representation of the list.
The flight list web resource is implemented by com.sun.jersey.samples.jsonfromjaxb.resources.FlightList
class.
The mapping of the URI path space is presented in the following table:
URI path | Resource class | HTTP methods |
---|---|---|
/flights/ | FlightList | GET, PUT |
Run the example as follows:
mvn clean compile exec:java
This deploys the JSON from JAXB example using Grizzly
A WADL description may be accessed at the URL:
http://localhost:9998/jsonfromjaxb/application.wadl
Following steps are using cURL command line tool:
Get the list of flights in JSON format:
curl -HAccept:application/json http://localhost:9998/jsonfromjaxb/flights
Get the list of flights in XML format:
curl -HAccept:application/xml http://localhost:9998/jsonfromjaxb/flights
You can also see test classes at src/main/test
subdirectory
for detail information how to consume the service using Jersey client API