应用 JAX-WS 创建 Web Services

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。他们不会运行在不是默认设定的端口上。

你可能感兴趣的:(应用 JAX-WS 创建 Web Services)