1 57 58 61 package org.apache.soap.transport; 62 63 import java.io.Reader ; 64 import java.io.Writer ; 65 import java.io.IOException ; 66 import org.apache.soap.SOAPException; 67 import org.apache.soap.Constants; 68 69 72 public class EnvelopeEditorAdapter implements EnvelopeEditor { 73 private static final int BUF_SIZE = 4096; 74 75 public void editIncoming(Reader in, Writer out) throws SOAPException { 76 passThrough(in, out); 77 } 78 79 public void editOutgoing(Reader in, Writer out) throws SOAPException { 80 passThrough(in, out); 81 } 82 83 protected void passThrough(Reader in, Writer out) throws SOAPException { 84 try { 85 char[] data = new char[BUF_SIZE]; 86 int len; 87 READ_LOOP: 88 while (true) { 89 int off = 0; 90 do { 91 if ((len = in.read(data, off, data.length - off)) == -1) { 92 out.write(data, 0, off); 93 break READ_LOOP; 94 } 95 } while ((off += len) < data.length); 96 out.write(data); 97 } 98 } catch(IOException e) { 99 throw new SOAPException(Constants.FAULT_CODE_SERVER, 100 e.getMessage(), e); 101 } finally { 102 try { 103 out.flush(); 104 } catch (IOException e) { 105 throw new SOAPException(Constants.FAULT_CODE_SERVER, 106 e.getMessage(), e); 107 } 108 } 109 } 110 } 111 114 | Popular Tags |