How do I get the entire ino:response document or XML respons

I’ve successfully used the JAVA API to create a connection and query the default ino:etc collection.

I get a TResponse object from the xmlObjectAccessor’s query method. There are various methods to get specific parts of the response (for example getReturnValue() or getFirstNonXMLObject())…

BUT, “How do I get the entire ino:response document or XML response?” That is, I want the complete response document.

From a TResponse object you can obtain the entire ino:response document by using:-

TResponse tresp = …
Document doc = (Document)(tresp.getFirstXMLObject().getDocument()) ;

Thank you. It worked.

I initially was getting the following class Exception when I tried to write the document out to an output stream using an XMLWriter class from a proprietary source: :confused:

Exception java.lang.ClassCastException: org.apache.crimson.tree.XmlDocument

And after several hours of tracking down the conflict(some jar file had this class hidden away some where) , and looking at alternative way to write out the document, I finally did the following:

org.w3c.dom.Document doc = (org.w3c.dom.Document)response.getFirstXMLObject().getDocument();

org.apache.xml.serialize.XMLSerializer serializer = new org.apache.xml.serialize.XMLSerializer();

And, Voila, the response document displayed to the screen. :slight_smile:

Most Excellent.

Thanks for the input. :cool:

To make this complete:
If you really want to get down to earth, you can always use the TStreamAccessor. With TStreamAccessor a query() returns a TInputStream with everything received from Tamino directly as a stream.