六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 1287|回复: 0

cxf 附件mtom方式

[复制链接]

升级  4%

12

主题

12

主题

12

主题

秀才

Rank: 2

积分
56
 楼主| 发表于 2013-2-7 10:04:51 | 显示全部楼层 |阅读模式
cxf附件传递:
spring配置文件:
<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:tx="http://www.springframework.org/schema/tx"xmlns:context="http://www.springframework.org/schema/context" xmlns:jaxws="http://cxf.apache.org/jaxws"xmlns:cxf="http://cxf.apache.org/core"xmlns:wsa="http://cxf.apache.org/ws/addressing"xsi:schemaLocation="    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd  http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsdhttp://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd   http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd"><import resource="classpath:META-INF/cxf/cxf.xml" /><import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" /><import resource="classpath:META-INF/cxf/cxf-servlet.xml" /><!-- 注解注入bean --><context:component-scan base-package="ws.upload" /> <cxf:bus>        <cxf:features>        <!--日志拦截功能,用于监控soap内容,开发后可以删除 -->             <cxf:logging/>            <wsa:addressing/>        </cxf:features>    </cxf:bus>  <jaxws:endpoint id="fileUploadWebServiceEndpoint"implementor="#fileUploadWebService"address="/uploadwebservice" ><jaxws:properties>              <!--开启mtom附件功能 --> <entry key="mtom-enabled" value="true"/></jaxws:properties></jaxws:endpoint></beans>
服务接口就不说了,直接贴实现类:
package ws.upload;import java.io.File;import java.io.FileOutputStream;import java.io.IOException;import java.io.InputStream;import java.io.OutputStream;import javax.activation.DataHandler;import javax.jws.WebService;import org.springframework.stereotype.Service;@WebService(endpointInterface="ws.upload.IFileUploadWebService")@Service("fileUploadWebService")public class FileUploadWebServiceImp implements IFileUploadWebService {@Overridepublic void upload(DataHandler dataHandler) {try {InputStream is=dataHandler.getInputStream();byte[] temp=new byte[1024];File file=new File("c:\\a.sql");OutputStream os=new FileOutputStream(file);int length=-1;while((length=is.read(temp))!=-1){System.out.println(length);os.write(temp);}} catch (IOException e) {e.printStackTrace();}}}
就完成服务段的编程了。

客户段附件里有。有兴趣的看一看看。
如果想了解mtom,可以看下面连接
http://boyingking.blog.sohu.com/27075328.html
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表