Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Also a JAX-WS SEI mmakes extensive use of annotations to specify the JAVA to WSDL mapping whereas this information does not exist in any form of JAX-RPC SEI (which requires jaxrpcmapping.xml to map JAVA to WSDL)

Deployment Descriptor

The deployment descriptor (web.xml) hasn't changed from JAX-RPC to JAX-WS where we just need to expose a POJO class as a servlet and JAXWSTools creates the artifacts on the fly whereas for JAX-RPC we need to specify the WSDL file locations.
With JAX-WS mapping to JavaEE5 and taking the advantage of annotations, the need for Web Service descriptor document webservices.xml is eliminated as a Web Service can be effectively described using the annotations

Client Port Lookup

The following code samples demonstrate the difference between JAX-RPC and JAX-WS in client port lookup.

Code Block
titleJAX-RPC Converter Client
borderStylesolid


package org.apache.geronimo.samples.jaxrpc;

import java.net.URL
import javax.xml.namespace.QName
import javax.xml.rpc.Service
import javax.xml.rpc.ServiceFactory
import javax.xml.rpc.ServiceException

//a part of client
URL url = new URL("http://localhost:8080/jaxrpc-converter/converter?wsdl");
QName qname = new QName("http://org.apache.geronimo.samples.jaxrpc/","ConverterService");
ServiceFactory factory = null;
Service service = null;
try {
	factory = ServiceFactory.newInstance();
	service = factory.createService(url, qname);
} catch (ServiceException e) {
	e.printStackTrace();
}
Converter conv = (Converter) service.getPort(Converter.class);

Code Block
titleJAX-WS Converter Client
borderStylesolid


package org.apache.geronimo.samples.jaxrpc;

import java.net.URL
import javax.xml.namespace.QName
import javax.xml.ws.Service

//a part of client
URL url = new URL("http://localhost:8080/jaxrpc-converter/converter?wsdl");
QName qname = new QName("http://org.apache.geronimo.samples.jaxrpc/","ConverterService");
Service service = Service.create(url, qname);
Converter conv = (Converter) service.getPort(Converter.class);

The main differences we can observe here are

  • The creation of ServiceFactory instance is no longer required for creating the Service
  • Service maps to javax.xml.rpc.Service in JAX-RPC and to javax.xml.ws.Service in JAX-WS

RESTful Services

JAX-WS introduced RESTful Web Services as successor for SOAP based Web Service. RESTful services already got quite support from many vendors like Google AdSense, Yahoo API's, Amazon etc
The important things that are introduced in JAX-WS to support RESTful services are:

Provider

Web service endpoints may choose to work at the XML message level by implementing the Provider interface. Here the endpoints access messages or message payloads using this low level, generic API.

Dispatch

The Dispatch API is intended for advanced XML developers who prefer to use XML constructs at the java.lang.transform.Source or javax.xml.soap.SOAPMessage level. For added convenience use of the Dispatch API with JAXB data-bound objects is supported

Asynchronous Operations

A major difference in operation mapping for JAX-WS over JAX-RPC is the introduction of asynchronous operations. Any WSDL operation with a two-way message flow, or one where the client expects to receive a response, can be mapped to an asynchronous Java representation
For further reference about asynchronous operations in JAX-WS refer to the references section.

MTOM and SAAJ

JAXWS 2.0 brings in support for optimized transmission of binary data as specified by MTOM (SOAP Message Transmission Optimization Mechanism) and SAAJ(SOAP with Attachments API for Java).
MTOM allows optimized transmission of binary data - any xs:base64Binary or xs:hexBinary schema type can be send as attachment following rules defined by MTOM specification.

References