Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Consuming XML in restful post

I have been doing lots of googling lately trying to find a decent documentation/tutorial to consume XML in JAVA RestFUL implementation of webservice. My requirements are simple

  • I want to consume XML

Which means that i need XML in raw. I don't need any JAXB binding or any objection conversation. Can someone point me to some decent tutorial or post something here

@POST
@Consumes(MediaType.APPLICATION_XML)
public void consumeXML (/*something here- duno what*/){
    //something here as well
}

thanks

like image 452
Em Ae Avatar asked May 04 '26 06:05

Em Ae


1 Answers

I would recommend specifying an InputStream as the method parameter.

@POST
@Consumes(MediaType.APPLICATION_XML)
public void consumeXML ( InputStream xml ){
    //do something with the XML string
}

Then the InputStream can be processed using any number of technologies: DOM, SAX, StAX, JAXB, etc.

like image 87
bdoughan Avatar answered May 05 '26 19:05

bdoughan