packagetest;importcom.wzh.MtomStreaming;importcom.wzh.MtomStreamingService;importjava.io.BufferedOutputStream;importjava.io.File;importjava.io.FileInputStream;importjava.io.FileNotFoundException;importjava.io.FileOutputStream;importjava.io.IOException;importjava.io.InputStream;importjava.io.OutputStream;importjavax.activation.DataHandler;public classTest {/***@paramargs the command line arguments*/
public static voidmain(String[] args) {
downloadFile();
}public static voiduploadFile(){
MtomStreamingService service= newMtomStreamingService();
MtomStreaming port=service.getMtomStreamingPort();
InputStream is;try{
is= new FileInputStream("/home/y/my_temp/tt.doc");
DataHandler upf= new DataHandler(newInputStreamDataSource(is));
String result= port.fileUpload("/home/y/my_temp2/tt.doc", upf);
System.out.println("==========upload result:"+result);
is.close();
}catch(FileNotFoundException e) {
e.printStackTrace();
}catch(IOException e) {
e.printStackTrace();
}
}public static voiddownloadFile(){
MtomStreamingService service= newMtomStreamingService();
MtomStreaming port=service.getMtomStreamingPort();
DataHandler dhn= port.fileDownload("/home/y/my_temp/22.doc");try{
File tempFile= new File("/home/y/my_temp/w01.doc");
OutputStream output= new BufferedOutputStream(newFileOutputStream(tempFile));
dhn.writeTo(output);
output.close();
System.out.println("====download");
}catch(IOException e1) {
e1.printStackTrace();
}
}
}