I am trying to work with the annotation based approach in Restlet using Jaxb
for XML binding. One of my goals to keep the code more consice than what I
would have done with Restlet 1.0.
@XmlRootEntity
public class Foo {
....
}
@XmlRootEntity
public class FooResponse {
....
}
1. Expect and Return Jaxb Objects
@Post("xml:xml")
public FooResponse createFoo(Foo foo) {
}
The above signature is similar to how a Post would be handled in JaxRS. I
however do not find automatic conversion of the XML payload into Foo.
2. Accept and Return JaxbRepresentations
@Post("xml:xml")
public JaxbRepresentation<FooResponse> createFoo(JaxbRepresentation<Foo> rep) {
...
}
With the above method as well, the argument to the method appears as null.
It appears that the Converter Service is not finding a match for converting
the xml payload into a JaxbRepresentation or Foo
3. Accept Representation
@Post("xml:xml")
public JaxbRepresentation<FooResponse> createFoo(Representation rep) {
JaxbRepresentation fooJaxbRep = new JaxbRepresentation(rep, Foo.class);
...
...
return new JaxbRepresentation<FooResponse>(...);
}
The above solution works for me. However, there are too many steps that I need
to write to get the JAXB object and provide a response.
If I decide that I would like to use JAXB through out my entire application, do
I need to extend and register a Custom Converter service to achieve either
option 1 or option 2?
Thanks in advance.
_________________________________________________________________
Windows Liveā¢: Keep your life in sync.
http://windowslive.com/explore?ocid=PID23384::T:WLMTAGL:ON:WL:en-US:NF_BR_sync:082009
------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2383870