import org.apache.axis.client.Call; import org.apache.axis.client.Service; import org.apache.axis.encoding.ser.*; import javax.activation.DataHandler; import javax.activation.FileDataSource; import javax.xml.namespace.QName; import java.io.FileOutputStream; public class SetFileTestClient { public SetFileTestClient() { try { //¸Å°³º¯¼ö ÀÖ´Â °æ¿ì ÆÄÀÏÀ» ã¾Æ ¼­¹ö·Î Àü¼ÛÇÑ´Ù. if(true) { String argFile = "a.gif"; java.io.File file = new java.io.File(argFile); if(!file.exists()) { System.err.println("error: file not found~!!!"); System.exit(8); } //¼­¹ö·Î ÆÄÀÏÀ» Àü¼ÛÇÑ´Ù. sendFile(file); } }catch(javax.xml.soap.SOAPException se) { se.printStackTrace(); } } //¼­¹ö·Î ÆÄÀÏÀ» Àü¼ÛÇÑ´Ù. @SuppressWarnings({ "unused", "rawtypes" }) private void sendFile(java.io.File file) throws javax.xml.soap.SOAPException { try { String endpoint = "http://localhost:8080/web.webservice6/services/AttachmentTest"; Service service = new Service(); //call °´Ã¼ »ý¼º Call call = (Call)service.createCall(); //¼­ºñ½º¸¦ Á¦°øÇÏ´Â ¼­¹öÀÇ À§Ä¡ ÁöÁ¤ call.setTargetEndpointAddress(new java.net.URL(endpoint)); //Serializer, deSerializer µî·Ï java.lang.Class jafsf = JAFDataHandlerSerializerFactory.class; java.lang.Class jafdf = JAFDataHandlerDeserializerFactory.class; java.lang.Class cls = DataHandler.class; javax.xml.namespace.QName qName = new javax.xml.namespace.QName("http://ws.apache.org/axis2", "DataHandler"); call.registerTypeMapping(cls, qName, jafsf, jafdf, false); //serializer, deSerializer µî·Ï //È£ÃâÇÒ ¸Þ¼Òµå µî·Ï call.setOperationName(new QName("http://ws.apache.org/axis2", "setFile")); // call.setOperationName(new QName("http://ws.apache.org/axis2", "test")); int a = 3; //ÆÄÀÏ °´Ã¼¸¦ FileDataSource¿¡ ´ã´Â´Ù. FileDataSource fileDataSource = new FileDataSource(file); //DataHandler¿¡ FileDataSource¸¦ ´ã¾Æ Àü´ÞÇÑ´Ù. DataHandler dhSource = new DataHandler(fileDataSource); //¸Å°³º¯¼ö¸¦ ³Ö¾î ¸Þ¼Òµå È£Ãâ Object ret = call.invoke(new Object[] {dhSource}); System.out.println("File send~!"); }catch(Exception e) { System.err.println(e.toString()); } } public static void main(String[] args) { System.out.println("ddddd"); new SetFileTestClient(); } }