zoukankan      html  css  js  c++  java
  • Axis 实现的SOAP附件的传输

    主要是将附件封装在请求头中,这样子客户端只要从请求头中下载下来即可。

    package com.test.soap.hello;
    
    import java.io.File;
    import java.net.URL;
    
    import javax.activation.DataHandler;
    import javax.xml.namespace.QName;
    import javax.xml.rpc.ParameterMode;
    import javax.xml.rpc.encoding.XMLType;
    
    import org.apache.axis.client.Call;
    import org.apache.axis.client.Service;
    import org.apache.axis.encoding.ser.JAFDataHandlerDeserializerFactory;
    import org.apache.axis.encoding.ser.JAFDataHandlerSerializerFactory;
    
    public class AxisFileTest {
    
    	public static void main(String[] args) throws Exception {
    
    		Service service = new Service();
    		Call call = (Call) service.createCall();
    
    		URL myUrl = new URL("http://192.168.1.164:1938");
    
    		call.setTargetEndpointAddress(myUrl);
    		call.setOperationName(new QName("urn:MyAttachServer", "echoDir"));
    
    		QName qnameAttachment = new QName("urn:MyAttachServer", "DataHandler");
    
    		call.registerTypeMapping(DataHandler.class, qnameAttachment,
    				JAFDataHandlerSerializerFactory.class,
    				JAFDataHandlerDeserializerFactory.class);
    		
    		call.addParameter("source", XMLType.XSD_STRING, ParameterMode.IN);
    		call.setReturnType(XMLType.SOAP_ARRAY);
    		
    		DataHandler[] ret = (DataHandler[]) call.invoke(new Object[]{null});
    		
    		for(int i = 0; i < ret.length; ++i){
    			
    			DataHandler recDH = ret[i];
    			File receivedFile = new File(recDH.getName());
    			System.out.println( i + ": " + receivedFile.getName() + "|length: " + receivedFile.length());
    		}
    		
    		
    		
    		
    
    	}
    }


  • 相关阅读:
    JTree单击事件
    hibernate、easyui、struts2整合
    ubuntu中wifi显示被硬件禁用的解决方法
    idea导入svn项目
    Intellij IDEA常用配置详解
    HBase 写优化之 BulkLoad 实现数据快速入库
    Spark性能优化之道——解决Spark数据倾斜(Data Skew)的N种姿势
    avro序列化详细操作
    wordcount代码实现详解
    idea配置maven
  • 原文地址:https://www.cnblogs.com/jingLongJun/p/4491104.html
Copyright © 2011-2022 走看看