1

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.

4

1 回答 1

3

如果你需要高性能,webservices 不是很好。

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

File : ImageServer.java //服务端点接口

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!");

    }

}
于 2013-01-22T08:14:56.647 回答