欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 编程资源 > 编程问答 >内容正文

编程问答

Axis 实现的SOAP附件的传输

发布时间:2025/5/22 编程问答 47 豆豆
生活随笔 收集整理的这篇文章主要介绍了 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附件的传输的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。