I use apache HTTP client to read the xml from a RESTful service and then parse it using DOM, SAX or JAXB. I don't have all schema files to generate java objects. SAX is used in few places. DOM is used mostly to read/write xml, but its is difficult to maintain as I have to write a parser for every document that is read. Is this a correct way to consume REST service? Do I really need to move to Jersey or Restlet in this case?
Have you taken a look at XStream http://xstream.codehaus.org/ ?
You do not need XML schemas to marshall and unmarshall, however it will use class instance field names as element names in the generated XML, so if your XML changes, you still need to modify the code.
Is Java 6 a requirement for Jersey? I cannot run it with Java5.
Joined: Jul 25, 2009
Nick Sher wrote:Is Java 6 a requirement for Jersey? I cannot run it with Java5.
works with Java 5
Joined: Jul 09, 2001
Jim Akmer wrote:@Dan: Why avoid JAXP?
If the web service request and response format is known, why should we parse manually the requests and responses? Let's automate it and simplify the web service code. Btw, I'm a bit fascinated by JAXB.
It should be noted that REST services need not necessarily return XML. If it's more convenient for some reason, JSON would be an alternative (especially if there's a chance that the service is consumed by a web browser).
Joined: Oct 04, 2006
Not really new stuff, but:
Just wrote a small program that "manually" parses XML using Groovy and the XmlSlurper class (http://groovy.codehaus.org/Reading+XML+using+Groovy%27s+XmlSlurper).
A refreshing experience, I must say!
Cannot vouch for the efficiency concerning memory usage and speed, though - haven't had time to look more closely into that part.