1

I'm using the Provider implementation of and wish to log the XML request prior to attempting to work with it, preferably using .

I've tried using TransformerFactory and stdout to log the incoming raw XML (below), which works, but when I do, the Source object can then no longer be used and generates NULL errors beyond the logging.

I'm assuming this is because it's a stream object and can only be used once.

private void printSource(Source source) {
    try {
        System.out.println("==========RESPONSE============");
        TransformerFactory factory = TransformerFactory.newInstance();
        Transformer transformer = factory.newTransformer();

        transformer.transform(source, new StreamResult(System.out));
        System.out.println("\n==============================");
    }
    catch(Exception e) {
        System.out.println(e.getMessage());
    }       
}
4

0 回答 0