Java Reference
In-Depth Information
status and containing a representation in the form of an Object entity and a Variant
is returned.
Using JAX-RS With JAXB
Java Architecture for XML Binding (JAXB) is an XML-to-Java binding technology that
simplifies the development of web services by enabling transformations between schema
and Java objects and between XML instance documents and Java object instances. An
XML schema defines the data elements and structure of an XML document. You can
use JAXB APIs and tools to establish mappings between Java classes and XML schema.
JAXB technology provides the tools that enable you to convert your XML documents to
and from Java objects.
By using JAXB, you can manipulate data objects in the following ways:
• You can start with an XML schema definition (XSD) and use xjc , the JAXB
schema compiler tool, to create a set of JAXB-annotated Java classes that map to
the elements and types defined in the XSD schema.
• You can start with a set of Java classes and use schemagen , the JAXB schema
generator tool, to generate an XML schema.
• Once a mapping between the XML schema and the Java classes exists, you can use
the JAXB binding runtime to marshal and unmarshal your XML documents to and
from Java objects and use the resulting Java classes to assemble a web services ap-
plication.
XML is a common media format that RESTful services consume and produce. To deseri-
alize and serialize XML, you can represent requests and responses by JAXB annotated
objects. Your JAX-RS application can use the JAXB objects to manipulate XML data.
JAXB objects can be used as request entity parameters and response entities. The JAX-
RS runtime environment includes standard MessageBodyReader and Mes-
sageBodyWriter provider interfaces for reading and writing JAXB objects as entities.
With JAX-RS, you enable access to your services by publishing resources. Resources are
just simple Java classes with some additional JAX-RS annotations. These annotations ex-
press the following:
• The path of the resource (the URL you use to access it)
• The HTTP method you use to call a certain method (for example, the GET or POST
method)
• The MIME type with which a method accepts or responds
Search WWH ::




Custom Search