1 package org.codehaus.xfire.wsdl; 2 3 import java.io.IOException; 4 import java.io.InputStream; 5 import java.io.OutputStream; 6 import java.net.URL; 7 import javax.wsdl.WSDLException; 8 9 /*** 10 * Create a WSDL instance from a URI. 11 * 12 * @author <a href="mailto:dan@envoisolutions.com">Dan Diephouse</a> 13 */ 14 public class ResourceWSDL 15 implements WSDL 16 { 17 String uri = null; 18 19 /*** 20 * @param wsdlUri 21 */ 22 public ResourceWSDL(String wsdlUri) throws WSDLException 23 { 24 this.uri = wsdlUri; 25 } 26 27 public void write(OutputStream out) throws IOException 28 { 29 URL url = new URL(uri); 30 31 copy( url.openStream(), out, 8096 ); 32 } 33 34 public void copy( final InputStream input, 35 final OutputStream output, 36 final int bufferSize ) 37 throws IOException 38 { 39 final byte[] buffer = new byte[bufferSize]; 40 41 int n = 0; 42 while (-1 != (n = input.read( buffer ))) 43 { 44 output.write( buffer, 0, n ); 45 } 46 } 47 }