Hi dev,

the usage of JaxbRepresentation is quite simple:

Java -> XML

public Representation represent(Variant variant) {

   ...
   Flight flight = ...
JaxbRepresentation jaxbRepOfMyFlight = new JaxbRepresentation(MediaType.TEXT_XML, flight);
   ...
   return jaxbRepOfMyFlight
}


XML -> Java

JaxbRepresentation jaxbRep = new JaxbRepresentation(response.getEntity(), "com.mycompany.entity.jaxb");
try {
   Flight flight = (Flight) jaxbRep.getObject();
   } catch (IOException e) {
           ...
}

where the package com.mycompany.entity.jaxb is the JAXB-context-path with the existing Java domain objects (eventually created vom xsd).

If you start from your domain objects and not from your xsd, I recommend using JIBX instead of JAXB. See also:
http://article.gmane.org/gmane.comp.java.restlet/3858/match=jibxRepresentation

There is an performance comparison between different XML binding frameworks at: http://www.ibm.com/developerworks/xml/library/x-databdopt2/

Cheers
Florian

dev dev schrieb:
Hi folks,

has anybody already used the JAXB XML binding framework with Restlet? Are there any sample codes we can take a look at on how it's being used in Restlet? Any performance issues we should seriously consider before using JAXB?

Thanks in advance for all the help.

dev

Reply via email to