Hi,
I have a REST webservice that listens to POST requests and grabs hold of an XML payload from the client and stores it initially as an InputStream i.e. on the Representation object you can call getStream().
I want to utilise the XML held in the InputStream and I am begining to think it would be wise to persist it, so I can interrogate the data multiple times - as once you read through it, the object becomes null. So I thought about converting the InputStream to a string. This is not a good idea as DocumentBuilder.parse() from javax.xml.parsers library will only allow you to pass:
- InputStreams
- Files
- URLs
- SAX InputSources
not strings.
What should I really be doing here with InputStreams in relation to parsing XML out of it? Bearing in mind I will want to re-interrogate that XML in future processes by the code.