1 22 package org.jboss.test.webservice.attachmentstepbystep; 23 24 import java.io.BufferedReader ; 25 import java.io.InputStream ; 26 import java.io.InputStreamReader ; 27 import java.net.URL ; 28 import java.rmi.RemoteException ; 29 import javax.activation.DataHandler ; 30 31 32 33 36 public class MyServiceImpl implements MyService 37 { 38 39 public MyServiceImpl() { 41 super(); 42 } 43 44 public DataHandler myService(DataHandler mimepart) throws RemoteException 45 { 46 URL url = null; 47 String result=""; 48 try { 49 InputStream is = mimepart.getInputStream(); 51 if (is != null) { 52 BufferedReader in = new BufferedReader (new InputStreamReader (is)); 53 54 String line=""; 55 line = in.readLine(); 56 result = "" + line; 57 while (line != null) 58 { 59 System.out.println(line); 60 line = in.readLine(); 61 result = result + line; 62 } 63 in.close(); 64 } 65 if (result.length() == 190) 67 { 68 url = new URL ("http://" + System.getProperty("jboss.bind.address", "localhost") + ":8080/myservice/resources/attachment_server2client.txt"); 69 } 70 else 71 { 72 throw new Exception ("The received file isn't 190 bytes length as expected. Length = " + result.length()); 73 } 74 } 75 catch (Exception ex) { 76 System.err.println(ex); 77 } 78 return new DataHandler (url); 79 } 80 81 82 } 83 | Popular Tags |