0

Am unable to find the way to convert StreamSource, SAXSource, DOMSource and Document Object to the User Entity. I have the following code.

Server Side:

@Path("/userResource")
public class UserResource {

    @POST
    @Path("StreamSource")
    public StreamSource getStreamSource(StreamSource streamSource) {
        return streamSource;
}

@POST
@Path("SAXSource")
public SAXSource getSAXSource(SAXSource saxSource) {
    return saxSource;
}

@POST
@Path("DOMSource")
public DOMSource getDOMSource(DOMSource domSource) {
    return domSource;
}

@POST
@Path("Document")
public Document getDocument(Document document) {
    return document;
}
}

User Bean is send from Jersey Client API and in return its working properly. Just not getting how should i access the StreamSource, SAXSource, DOMSource and Document Object on Server Side.

Is there any API available for conversion ?

Sunil Gulabani
  • 878
  • 1
  • 8
  • 21
  • It entirely depends on your binding framework if any.... if you're using JAXB, JAXB.unmarshall will accept more or less any Source type. You can also pass any of them through the identity transform with a content handler that maps to custom objects. This doesn't look like a particularly sane approach -- what exactly are you trying to do? All of these end points will accept the exact same XML -- the only difference is how it's being transformed before your method is called. – lscoughlin Sep 25 '13 at 13:13
  • Am trying to access the User Object at server end. I have this code at the server and From Client API, am sending the User Bean. https://jersey.java.net/documentation/latest/media.html#d0e5801 I tried getting parsing the InputStream from StreamSource, but it providing no content. – Sunil Gulabani Sep 25 '13 at 13:33
  • Examples of how to do what you actually want: https://jersey.java.net/download.html – lscoughlin Sep 25 '13 at 14:11

0 Answers0