Java Reference
In-Depth Information
Listing 8.7. Bid DTO class using JAXB annotations
The DTO shown in listing 8.7 will result in the output shown in the next listing when the
getBid method is invoked and XML is returned. This should give you a good idea of how
the JAXB annotations drive the XML generation.
Listing 8.8. Bid DTO XML output example
<Bid bidId="10">
<bidDate>2012-05-15T20:01:35.088-04:00</bidDate>
<bidPrice>10.0</bidPrice>
<itemId>45</itemId>
<bidderId>77</bidderId>
</Bid>
If the client informs the getBid service that it wants JSON as the response instead, the
output in the following listing will be returned instead of the XML. The JSON output is
ideal for use by Web 2.0 applications written in JavaScript or for smartphones. When it gets
read in by the client, the client will access it as a hash map, which is much easier to work
with than XML.
 
Search WWH ::




Custom Search