允许大文件流传输的 Java Web 服务 [英] Java web services to allow large file streaming

查看:41
本文介绍了允许大文件流传输的 Java Web 服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个需要扩展和高度可用的 Java Web 服务服务器.用户可以通过服务上传大文件(~20M).SOAP 是首选.

I am building a java web services server that needs to scale and to be highly available. User can upload large file (~20M) through the services. SOAP is preferred.

我的问题是:有没有这样一个支持大文件流的网络服务框架?我应该考虑任何构建块?有什么好的做法吗?

My question are: is there any such a web service framework which support large file streaming? Any building blocks that I should consider? Any good practices?

任何想法将不胜感激.谢谢.

Any thoughts would be appreciated. Thanks.

推荐答案

如果您需要高性能,网络服务不是很好.

If you need high performance, webservices are not great.

您可以尝试(流式 SOAP 附件):

You can try (Streaming SOAP Attachments):

文件:ImageServer.java//服务端点接口

File : ImageServer.java //Service Endpoint Interface

package com.mkyong.ws;     
import java.awt.Image; 
import javax.jws.WebMethod;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.jws.soap.SOAPBinding.Style;



@WebService
@SOAPBinding(style = Style.RPC)
public interface ImageServer{

    //download a image from server
    @WebMethod Image downloadImage(String name);

    //update image to server
    @WebMethod String uploadImage(Image data);

}

//File : ImageServerImpl.java
package com.mkyong.ws;

import java.awt.Image;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;
import javax.jws.WebService;
import javax.xml.ws.WebServiceException;
import javax.xml.ws.soap.MTOM;

//Service Implementation Bean
@MTOM
@WebService(endpointInterface = "com.mkyong.ws.ImageServer")
public class ImageServerImpl implements ImageServer{

    @Override
    public Image downloadImage(String name) {

        try {

            File image = new File("c:\\images\\" + name);
            return ImageIO.read(image);

        } catch (IOException e) {

            e.printStackTrace();
            return null; 

        }
    }

    @Override
    public String uploadImage(Image data) {

        if(data!=null){
            //store somewhere
            return "Upload Successful";
        }

        throw new WebServiceException("Upload Failed!");

    }

}

这篇关于允许大文件流传输的 Java Web 服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆