Web services JavaRESTEasyWebService-从HTTPResponse对象下载图像文件。

Web services JavaRESTEasyWebService-从HTTPResponse对象下载图像文件。,web-services,Web Services,我需要使用RESTEasy web服务从文件系统下载一个图像文件,输入httpclient为JSON,输出响应为 @产生({“image/jpeg,image/png”}) 这是我的客户代码: public void getFileDownload(){ log("inside getServerPath...."); DefaultHttpClient httpClient = new DefaultHttpClient(); HttpPo

我需要使用RESTEasy web服务从文件系统下载一个图像文件,输入httpclient为JSON,输出响应为
@产生({“image/jpeg,image/png”})

这是我的客户代码:

public void getFileDownload(){  
        log("inside getServerPath....");
        DefaultHttpClient httpClient = new DefaultHttpClient();

        HttpPost httpPost = new HttpPost(downloadWebService_URL);
        JSONObject json = new JSONObject();
        json.put("filePath", "/ngs/app/sample.png");
        json.put("fileName", "sample.png");

        log("json-->"+json.toString());

        StringEntity inputJson = null;
        try {
            inputJson = new StringEntity(json.toString());
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        } 
        log("inputJson = " + inputJson.toString());

        inputJson.setContentType("application/json");
        httpPost.setEntity(inputJson);
        httpPost.addHeader("AppType", "TC");

        log("httpPost... httpPost");
        HttpResponse response = null; 
        try {
            response = httpClient.execute(httpPost);
            log("response:-->"+response);
        }
        catch (ClientProtocolException e) {
            e.printStackTrace();
        }
        catch (IOException e) { 
            e.printStackTrace();
        }

        catch (Exception e) 
        {
            log("E:: " + ExceptionUtils.getStackTrace(e));
        }
    }
以下是我的Web服务代码:

@Path("/downloadservice")
public class DownloadFileWS {

  private static final String FILE_PATH = "/ngs/app/sample.png";

    @POST  
   // @Path("/images") 
    @Path("/{fileName}/images")
    @Consumes({"application/json"}) 
    @Produces({"image/jpeg,image/png"})
    public Response getImageFile(@PathParam("fileName") String fileName) {  
        File file = new File(FILE_PATH);    
        System.out.println("File requested is : " + fileName);
        Logger.getLogger("!!!!!!!!!!!"+FILE_PATH);
        System.out.println("@@@@@@@@"+FILE_PATH);
        ResponseBuilder response = Response.ok((Object) file);  
        response.header("Content-Disposition","attachment; filename=\"sample.png\""); 
        return response.build();  
    }  
HTTP响应是:

回复:-->HTTP/1.1 200正常[日期:2016年7月19日星期二00:36:22 GMT, 内容长度:6192,内容类型:图像/png,内容配置: 附件;filename=“sample.png”,X-Powered-By:Servlet/2.5 JSP/2.1] org.apache.http.conn。BasicManagedEntity@2ace1307

问题: 1.根据响应,服务似乎正在HTTPResponse对象中发送图像。我可以知道如何下载从HTTP响应接收到的图像吗?
2.要求是通过将JSON作为输入请求传递,单击调用web服务的链接,图像应自动下载到用户的本地计算机浏览器。

在Resteasy web服务调用期间,有人能告诉我如何在客户端/用户浏览器中将HttpResponse作为文件下载吗?有人能告诉我如何下载吗在Resteasy web服务调用期间,是否将HttpResponse作为文件下载到客户端/用户浏览器中?