首页>代码>axis2 webservice实现文件上传删除功能>/FileUploadInfo/src/com/fileup/upfileclient/FileUploadClient.java
package com.fileup.upfileclient;

import java.io.File;
import java.io.FileInputStream;
import java.util.Date;

import javax.xml.namespace.QName;

import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.Options;
import org.apache.axis2.rpc.client.RPCServiceClient;

import com.fileup.util.UtilFile;

/**
 * webservice 文件上传测试代码
 * 
 * @author root
 * 
 */
public class FileUploadClient {
	
	public static void main(String[] args) throws Exception {
		//指定要上传文件的路径
	    String fileName = "C:\\Users\\root\\Desktop\\activation-1.1.jar";
		RPCServiceClient sc = new RPCServiceClient();
		Options options = sc.getOptions();
		EndpointReference erf = new EndpointReference(
				"http://localhost:8088/FileUploadInfo/services/upload_service");
		options.setTo(erf);
		
		File file = new File(fileName);
		FileInputStream in = new FileInputStream(file);
		byte[] bs = new byte[in.available()];
		in.read(bs);
		
		Object[] opAddEntryArgs = new Object[] { "测试上传", UtilFile.fileEndName(fileName) ,bs };
		if (in != null) {
			in.close();
		}
		// 设置返回值类型
		Class<?>[] classes = new Class<?>[] { String.class };
		// 命名空间和方法名称
		QName qname = new QName("http://upservice.fileup.com", "uploadFile");
		// 执行文件上传,接收返回值
		Object returnValue = sc.invokeBlocking(qname,
				opAddEntryArgs, classes)[0];
		System.out.println(new Date() + " 文件上传结束,返回值:" + returnValue);
	}
}
最近下载更多
1358849392  LV21 2023年11月18日
mengyr  LV3 2022年3月21日
Gustav_1  LV1 2019年5月29日
plushenko  LV1 2019年2月25日
chinafjfzlj  LV31 2018年10月27日
zjjhzjb  LV14 2018年9月13日
十年后  LV15 2018年5月23日
fengyaofei  LV16 2017年12月13日
nan_fan  LV10 2017年7月21日
剑是道  LV9 2017年6月23日
最近浏览更多
mengyr  LV3 2022年3月21日
lizw007  LV10 2022年1月22日
疯狂的爱人  LV11 2021年6月10日
哎呀  LV1 2021年5月15日
爱情戴罪的羔羊  LV7 2021年2月24日
沉醉不知归wd  LV6 2020年8月11日
多吃多占  LV12 2020年6月8日
luolukka  LV8 2020年5月31日
能不能不存在  LV13 2020年5月15日
hola123  LV3 2020年5月14日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友