users@jersey.java.net

Re: [Jersey] Is Jersey capable of Implementing File Post

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Thu, 19 Nov 2009 12:57:38 +0100

On Nov 19, 2009, at 12:43 PM, Anil Kumar Veeramalli wrote:

> Hi,
>
> Here is my requirement, Please suggest me whether Jersey API's are
> capable enough or not.
>
>
> 1) Build RESTful webservice which will consume the inbound XML
> documents. XML documents will be different every time when we invoke
> webserice.

Yes. What XML API do you want to use to parse the XML documents?

Although the XML documents will be different will the structure be
well-defined, namly will there be a schema or will it be possible to
unmarshall such documents using JAXB?

JAX-RS/Jersey supports the types org.w3c.dom.Document as well as
StreamSource, SAXSource and DOMSource for processing request entities.

For example:

   @POST
   public ... post(Document d) { ... }

JAX-RS/Jersey also supports JAXB and is also capable of utilizing the
Object type if there is an unmarshaller capable of supporting that by
declaring a ContextResolver<JAXBContext> or
ContextResolver<Unmarshaller> that returns JAXBContext or Unmarshaller
for the type Object. I can send more details on that if you require.

You can also plug in your own API using the JAX-RS MessageBodyWriter
for any other XML-based APIs you might want to use.


> 2) Parse XML document and populate Mysql database.
>
> Step2 is possible its nothing to do with Jersey.

Correct. That step could be very tricky of the structure if the set of
XML documents you consume is not defined by a schema (or does not
conform a well-defined structural pattern).

Paul.