http://netbeans.org/kb/docs/websvc/flower_overview_zh_CN.html 

Web Service Application Passing Binary Data, pt 1: Overview(通过 Web 服务传递二进制数据,第 1 部分:概述)

In this tutorial, you create an EE6 web application that contains a web service, which you implement as a stateless session bean.(在本教程中,将创建一个包含 Web 服务的 EE6 Web 应用程序,该应用程序将作为无状态会话 Bean 来实现。) You also add a package with four JPEG files to the web application. (同时还会向该 Web 应用程序添加包含四个 JPEG 文件的包。)The web service has two operations that are accessible by clients, for getting individual p_w_picpaths and for getting a set of all 4 p_w_picpaths as thumbnails(缩略图). (Web 服务有两种操作可供客户端访问,一是获取单个图像,二是以缩略图形式获取一组所有 4 个图像。)You add private methods that convert the JPEG files to byte arrays and convert those byte arrays to Image objects. (将添加一些私有方法,用于将 JPEG 文件转换为字节数组,然后将这些字节数组转换为Image 对象。)Unlike the case with Java EE5, in EE6 you put these private methods directly in the web service, because the web service is also an EJB.(与 Java EE5 中的情况不同,在 EE6 中,将这些私有方法直接放在 Web 服务中,因为 Web 服务还是一个 EJB。)

After you create the web service, you deploy it to an instance of the GlassFish server 3.1 (Due to a bug, you cannot use 3.0.1.)(在创建 Web 服务后,将其部署到 GlassFish Server 3.1 的实例(由于存在错误,您无法使用 3.0.1。))You use the NetBeans IDE's built-in web service tester to view sample SOAP request and response messages.(使用 NetBeans IDE 的内置 Web 服务测试器可查看样例 SOAP 请求和响应消息。)

The default JAX-WS service infrastructure(基础设施) cannot inform clients that the binary data needs to be interpreted(解释) as JPEG files. (默认的 JAX-WS 服务基础结构无法通知客户端需要将二进制数据解释为 JPEG 文件。)Therefore, you generate a copy of the XML Schema and WSDL files and edit the XML schema to tell any client to expect the p_w_picpath/jpeg content type for the return element.(因此,将生成一个 XML 方案的副本以及 WSDL 文件,然后编辑 XML 方案以告知任何客户端期望的返回元素是 p_w_picpath/jpeg 内容类型。) You also alter the service code to use the customized WSDL and Schema.(还将更改服务代码以使用定制的 WSDL 和方案。)

Finally, you create a Java client application that displays the p_w_picpaths in an album(相簿) created from Swing components.(最后,将创建一个 Java 客户端应用程序,用于在相册中显示通过 Swing 组件创建的图像。)

You can download a complete version of service and client applications from the NetBeans Samples Catalog.(可以从 

NetBeans 样例目录中下载完整版本的服务和客户端应用程序。)

Lessons In This Tutorial(本教程中的课程

1. Overview(概述

2.Creating the Web Service(创建 Web 服务)

3.Coding and Testing the Web Service(对 Web 服务进行编码和测试

4.Modifying the Schema and WSDL Files to Pass Binary Data(修改方案文件和 WSDL 文件以传递二进制数据)

5.Creating the Swing Client(创建 Swing 客户端

Software Needed for the Tutorial(本教程所需要的软件)

To follow this tutorial, you need the following software and resources.(本教程所需要的软件

Software or Resource(软件或资源) Version Required(要求的版本)
NetBeans IDE Java EE download bundle(Java EE 下载包)
Java Development Kit (JDK)(Java 开发工具包 (JDK)) version 6 or version 7(版本 6 或版本 7)
Java EE-compliant(兼容) web or application serve(符合 Java EE 规范的 Web 服务器或应用服务器) GlassFish Server Open Source Edition 3.1 Warning: Due to issues with GlassFish 3.0.1 final release, you have to use the 3.1 version(警告:由于 GlassFish 3.0.1 最终发行版存在问题,您必须使用 3.1 版本。)
Pictures used in this tutorial(本教程中使用的图片)

rose.jpg

sunflower.jpg

aster.jpg

honeysuckle.jpg

Note: the GlassFish server can be installed with the Java EE download bundle of NetBeans IDE. Alternatively, you can visit the the GlassFish server downloads page.(注:GlassFish Server 可以随同 NetBeans IDE 的 Java EE 下载包一起安装。或者,还可以访问 GlassFish Server 下载页)

Tip: Optionally, for troubleshooting(故障诊断) purposes, you can download the completed sample and inspect(检查) the sources.(提示:(可选)要解决疑难问题,可以下载完整的样例并查看其源代码)

At the end of this tutorial, you will have a running Java Swing application that consumes JPEG p_w_picpaths via a web service, with the result displayed below.(执行完本教程中的操作后,将具有一个可运行的 Java Swing 应用程序,它通过 Web 服务使用 JPEG 图像,具体结果显示如下。)

Web Service Application Passing Binary Data, pt 1: Overview_第1张图片