cxf文件上传运行实例
?web.xml
?启动并运行项目
package com.test;import java.io.File; import javax.activation.DataHandler; import javax.activation.DataSource; import javax.activation.FileDataSource; import org.apache.cxf.jaxws.JaxWsProxyFactoryBean; import com.yunix.service.entity.FileEntity;import com.yunix.service.webservice.IFileService; public class Test { public static void main(String[] args) throws Exception { String url = "http://localhost:8080/service-file/fileService?wsdl"; FileEntity file = new FileEntity(); file.setFileName("2012-03-04TestFile"); file.setFileType("jpg"); DataSource source = new FileDataSource(new File("d:\\123456.jpg")); file.setFile(new DataHandler(source)); JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean(); factory.setServiceClass(IFileService.class); factory.setAddress(url); IFileService client = (IFileService) factory.create(); try { client.uploadFile(file); } catch (Exception e) { System.out.println(e); } System.out.println("success"); } }?