About Question enthuware.ocejws.v6.2.190 :

Moderators: Site Manager, fjwalraven

Post Reply
himaiMinh
Posts: 358
Joined: Fri Nov 29, 2013 8:26 pm
Contact:

About Question enthuware.ocejws.v6.2.190 :

Post by himaiMinh »

In Jersey, by default, Source, JAXBElement and any JAXB annotated objects can be serialized into application/xml media type by the standard entity provider.

However, the Jersey tutorial does not say org.w3c.dom.Document can be serialized into xml.
However, this option works fine and return XML output:

Code: Select all

@Produces("application/xml")
public Document postDocument(...){....}
The reason why it works, maybe because other dependency jar files on the classpath, like jdom.jar .
Any comments?

himaiMinh
Posts: 358
Joined: Fri Nov 29, 2013 8:26 pm
Contact:

Re: About Question enthuware.ocejws.v6.2.190 :

Post by himaiMinh »

To answer my own question, I just found out there is a DocumentProvider.class in com.sun.jersey.core.impl.provider.entity package. I searched for the code online :

Code: Select all

From : http://grepcode.com/file/repo1.maven.org/maven2/com.sun.jersey/jersey-core/1.1.4.1/com/sun/jersey/core/impl/provider/entity/DocumentProvider.java
@Produces({"application/xml", "text/xml", "*/*"})
@Consumes({"application/xml", "text/xml", "*/*"})

public final class   DocumentProvider extends AbstractMessageReaderWriterProvider<Document> {...}
This is the entity provider that read/write Document to and from XML.

It is just this standard entity provider is not mentioned in the Jersey tutorial.

fjwalraven
Posts: 429
Joined: Tue Jul 24, 2012 2:43 am
Contact:

Re: About Question enthuware.ocejws.v6.2.190 :

Post by fjwalraven »

Jersey tutorial v1.17 chapter 4.1 Low level XML support

Code: Select all

1 @Path("1")
2 @POST
3 public StreamSource get1(StreamSource streamSource) {
4   return streamSource;
5 }
6
7 @Path("2")
8 @POST
9 public SAXSource get2(SAXSource saxSource) {
10 return saxSource;
11 }
12
13 @Path("3")
14 @POST
15 public DOMSource get3(DOMSource domSource) {
16   return domSource;
17 }
18
19 @Path("4")
20 @POST
21 public Document get4(Document document) {
22   return document;
23 }

Post Reply

Who is online

Users browsing this forum: No registered users and 21 guests