Building Web Services with JAX-WS#
Java API for XML Web
Services (JAX-WS) is a technology for building web services and clients that
communicate using XML. JAX-WS allows developers to write message-oriented as well as Remote Procedure Call-oriented (RPC-oriented) web services.
Java 面向 XML Web Service(JAX-WS) API 是為了創建web services 和 客戶端能夠應用 xml 進行通信的技術。 JAX-WS 允許開發人員寫面向消息的同時面向遠程程序調用的web services(RPC-oriented)。
In JAX-WS, a web service operation invocation is represented by an XML-based protocol, such as
SOAP. The SOAP specification defines the envelope structure, encoding rules, and
conventions for representing web service invocations and responses. These calls
and responses are transmitted as SOAP messages (XML files) over HTTP.
使用 JAX-WS,一個web service 操作調用是通過一個基于XML協議來代表的,例如SOAP。SOAP規范定義了信封接口,編碼規則和代表web service請求和響應的約束。這些請求和響應通過HTTP作為SOAP消息(XML files)進行傳輸。
Although SOAP messages are complex, the JAX-WS API
hides this complexity from the application developer. On the server side, the
developer specifies the web service operations by defining methods in an
interface written in the Java programming language. The developer also codes one
or more classes that implement those methods. Client programs are also easy to
code. A client creates a proxy (a local object representing the service) and
then simply invokes methods on the proxy. With JAX-WS, the developer does not
generate or parse SOAP messages. It is the JAX-WS runtime system that converts
the API calls and responses to and from SOAP messages.
盡管SOAP消息很復雜,JAX-WS API 將這種復雜性對應用程序開發者進行了隱藏。在服務端,開發者通過用Java語言在一個接口中定義方法來指定web service操作。開發者通常編寫一個或多個類來實現這些方法。客戶端程序也很容易編寫。一個客戶創建一個代理(一個本地對象來代表服務)然后簡單的在代理上調用這個方法。應用 JAX-WS,開發者不用生成或是解析SOAP消息。 JAX-WS運行時系統從 SOAP消息轉換成API請求和響應。
With JAX-WS, clients and web
services have a big advantage: the platform independence of the Java programming
language. In addition, JAX-WS is not restrictive: A JAX-WS client can access a
web service that is not running on the Java platform, and vice versa. This
flexibility is possible because JAX-WS uses technologies defined by the W3C:
HTTP, SOAP, and WSDL. WSDL specifies an XML format for describing a service as a
set of endpoints operating on messages.
應用 JAX-WS,客戶和webservices 有一個很大的優勢:平臺獨立于Java語言。并且JAX-WS是沒有限制的:一個 JAX-WS的客戶端可以獲取不是在Java平臺上運行的webservice,反之亦然。之所以會這么靈活是因為JAX-WS是基于W3C定義的:HTTP,SOAP,和WSDL。 WSDL 指定一種XML格式 用來描述一個服務作為一組在消息服務上的端點。
Note -
Several files in the JAX-WS examples depend on the port that
you specified when you installed the GlassFish Server. These tutorial examples
assume that the server runs on the default port, 8080. They do not run with a
non default port setting.
筆記-
當你安裝完GlassFish 服務器之后,一些基于JAX-WS的文件將會依賴你指定的端口。這些教材例子默認你的服務運行在默認端口8080。他們不會運行在不是默認設定的端口上。