Axis 实现的SOAP附件的传输
生活随笔
收集整理的這篇文章主要介紹了
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());}} }轉載于:https://www.cnblogs.com/jingLongJun/archive/2013/05/15/4491104.html
總結
以上是生活随笔為你收集整理的Axis 实现的SOAP附件的传输的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 一般函数指针和类(非MFC)的成员函数指
- 下一篇: Page类的IsPostBack原理