cxf 附件mtom方式

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.xsd
http://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 {

@Override
public 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
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值