title: Logging XML request in Java-WS invoke method
body: <p>I'm using the Provider implementation of <a href="/questions/tagged/java-ws" class="post-tag" title="show questions tagged 'java-ws'" rel="tag">java-ws</a> and wish to log the XML request prior to attempting to work with it, preferably using <a href="/questions/tagged/log4j" class="post-tag" title="show questions tagged 'log4j'" rel="tag">log4j</a>.  </p>
  
  <p>I've tried using <code>TransformerFactory</code> and <code>stdout</code> 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.  </p>
  
  <p>I'm assuming this is because it's a stream object and can only be used once.</p>
  
  <pre><code>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());
      }       
  }
  </code></pre>