Login | Register   
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

JAX-RPC Evolves into Simpler, More Powerful JAX-WS 2.0

The new Java Architecture for XML Web Services (JAX-WS) will replace JAX-RPC in the upcoming Java EE 5 and Java 6 (codename: Mustang). Learn all about JAX-WS 2.0 and see how to use it to transform a Java class into a Web service.


advertisement
s of version 2.0, JAX-RPC has been renamed JAX-WS. But the change is not in name alone. JAX-WS offers simplified development, better platform and language independence, and an end to the chaotic array of earlier Java Web services frameworks. This article explores the high-level architecture of JAX-WS, along with its low-level inner workings. It then walks you step by step through creating your first JAX-WS Web service.

What You Need
The latest version of Java 5
Tomcat (5.5 or later)
Ant (1.6 or later)
JAX-WS



The Architecture of JAX-WS 2.0

Click to enlarge
Figure 1. JAX-WS High-Level Architecture

What is the JAX-WS? Essentially, it consists of the following four things:

  1. An API for developing Web services using Java and XML
  2. A standard implementation (SI, as in JAXWS-SI.jar) of the Web services servlet
  3. Annotations, such as @WebService, that are processed by apt (annotation processing tool) to generate components for the service and client (A list of all JAX-WS annotations can be found here.)
  4. A set of tools (primarily wsimport) for generating the "portable artifacts" (beans, stubs, and XML) for the client code. (wsimport stands for Web service import, which reads in the descriptors of the published Web service and generates the client artifacts.)

Clearly, JAX-WS is more than just an API for building Web services. Figure 1 shows its high-level architecture.

JAX-WS Under the Hood

How does a JAX-WS application work? The developer need be exposed only to the client and service endpoint. The rest is generated and run automatically (see Figure 2).

Click to enlarge
Figure 2. JAX-WS: How It Works

On the client side, the only Java file the developer supplies is the client class itself. The interface and JavaBeans are generated automatically by wsimport. On the server side, the only Java file the developer supplies is the service implementation. The JavaBeans are generated by apt, and the servlet is part of the JAX-WS library.

The generated JavaBeans (also known as a type of portable artifact) are responsible for marshaling/unmarshaling method invocations and responses, as well as service-specific exceptions. Marshaling and unmarshaling are the transformation from XML to Java objects and back using JAXB. Two JavaBeans are generated for each method in the Web service. One bean is for invoking the method and the other for handling the response. An additional JavaBean is generated for each service-specific exception. (JAX-WS 2.0 Beta User's Guide 3.1.1.1 Generate Portable Artifacts)



Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap