Package org.springside.examples.showcase.ws.server.result

Examples of org.springside.examples.showcase.ws.server.result.SmallImageResult


    proxyFactory.setAddress(address);
    proxyFactory.setServiceClass(SmallImageWebService.class);
    SmallImageWebService imageService = (SmallImageWebService) proxyFactory.create();

    //调用SmallImageService
    SmallImageResult result = imageService.getImage();
    assertTrue(result.getImageData().length > 0);

    //保存图片文件并校验
    String tempFilePath = System.getProperty("java.io.tmpdir") + "smalllogo.jpg";
    OutputStream os = new FileOutputStream(tempFilePath);
    IOUtils.write(result.getImageData(), os);
    IOUtils.closeQuietly(os);
    System.out.println("图片已保存至" + tempFilePath);
  }
View Full Code Here


      //采用applicationContext的getResource()函数获取Web应用中的文件.
      is = applicationContext.getResource("/img/logo.jpg").getInputStream();
      //读取内容到字节数组.
      byte[] imageBytes = IOUtils.toByteArray(is);

      SmallImageResult result = new SmallImageResult();
      result.setImageData(imageBytes);
      return result;
    } catch (IOException e) {
      logger.error(e.getMessage(), e);
      return WSResult.buildResult(SmallImageResult.class, WSResult.IMAGE_ERROR, "Image reading error.");
    } finally {
View Full Code Here

TOP

Related Classes of org.springside.examples.showcase.ws.server.result.SmallImageResult

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.