⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fileservicegetclient.java

📁 精通Jboss——Ejb和Web Services开发精解的随书源代码
💻 JAVA
字号:
package com.liuyang.axis.soapattachment;

import java.net.URL;
import javax.activation.DataHandler;
import javax.xml.namespace.QName;
import javax.xml.rpc.ParameterMode;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.encoding.XMLType;
import org.apache.axis.encoding.ser.JAFDataHandlerDeserializerFactory;
import org.apache.axis.encoding.ser.JAFDataHandlerSerializerFactory;
public class FileServiceGetClient {
	public static void main(String[] args) throws Exception {
		Service service = new Service();
		Call call = (Call) service.createCall();
		String endpoint = "http://localhost:8080/axis/services/FileService";
		call.setTargetEndpointAddress(new URL(endpoint));
		call.setOperationName(new QName("FileService", "getFile")); 
		QName qnameAttachment=new QName("http://localhost:8080/axis/services/FileService","DataHandler");
		call.registerTypeMapping(DataHandler.class,qnameAttachment,
			JAFDataHandlerSerializerFactory.class,JAFDataHandlerDeserializerFactory.class);
		call.addParameter("s",XMLType.XSD_STRING ,ParameterMode.IN);
		call.setReturnType(qnameAttachment);
		Object ret = call.invoke(new Object[]{"test.txt"});
		if(ret instanceof DataHandler){
			DataHandler dadahandler = (DataHandler) ret;
			System.out.println(dadahandler.getContent());
		}else{
			System.out.println("result is null");
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -