Web Service Application Passing Binary Data, pt 1: Overview

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 圖像,具體結果顯示如下。)

 

 

 

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章