1 package org.codehaus.xfire.client.http; 2 3 import java.io.ByteArrayOutputStream; 4 5 import javax.xml.stream.XMLOutputFactory; 6 import javax.xml.stream.XMLStreamException; 7 import javax.xml.stream.XMLStreamReader; 8 import javax.xml.stream.XMLStreamWriter; 9 10 import org.codehaus.xfire.client.NullRequestHandler; 11 import org.codehaus.xfire.util.STAXUtils; 12 13 /*** 14 * @author <a href="mailto:dan@envoisolutions.com">Dan Diephouse</a> 15 * @since Oct 26, 2004 16 */ 17 public class SinkHandler 18 extends NullRequestHandler 19 { 20 private String response; 21 22 public void handleResponse(XMLStreamReader reader) throws XMLStreamException 23 { 24 ByteArrayOutputStream out = new ByteArrayOutputStream(); 25 26 XMLOutputFactory factory = XMLOutputFactory.newInstance(); 27 28 XMLStreamWriter writer = factory.createXMLStreamWriter(out); 29 30 STAXUtils.copy(reader, writer); 31 32 writer.close(); 33 34 this.response = out.toString(); 35 } 36 37 38 /*** 39 * @return Returns the response. 40 */ 41 public String getResponse() 42 { 43 return response; 44 } 45 }