Versions Compared

Key

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

...

Even though JAX-RPC is still supported by Sun, it lacks many advanced features that JAX-WS has like Annotations, JAXB Binding, SOAP 1.2, RESTful Services etc. So It is strongly recommended that you use JAX-WS instead of JAX-RPC for implementing Web Services in Java.

...

The most notable change in JAX-WS 2.0 is the use of JAXB 2.0 for data-binding between Java and XML. JAX-RPC 1.0 specified a limited mapping between XML and Java.
This effectively eliminates the need of using jaxrpcmapping.xml where we define the mapping between Java and WSDL. But also imposes a condition that the return and request values can be able to bind to JAXB. Again, considering the wide variety of data types supported by JAXB it shouldn't be a problem.

Info
titleJAX-RPC & JAXB

JAX-RPC didn't used JAXB because the first version of JAX-RPC is completed much before JAXB. So, instead of waiting for JAXB to complete JAX-RPC writers developed their own custom mapping.

Annotations

JAX-WS 2.0 relies heavily on the use of Annotations. These annotations are used to customize the mapping from JAVA to XML schema/WSDL and are used at runtime to create the necessary files.
Geronimo uses the Sun provided JAXWSTools utility to create the WSDL file and another stubs on the fly at the deploy time by processing the annotations specified.

SOAP Standards

JAX-RPC and JAX-WS both support SOAP 1.1. The default binding supported by JAX-WS is SOAP 1.1 over HTTP. But it can also support SOAP 1.2 binding over HTTP. As a java programmer you might not encounter any difference between SOAP 1.1 and SOAP 1.2

Service Endpoint Interface Requirements

As per JAX-RPC a Service Endpoint Interface must extend Remote. JAX-WS removes this condition and you can pretty much make a POJO class a Web Service by just adding the @WebService annotation at the top of the class.

Code Block
titleJAX-RPC Converter SEI
borderStylesolid


package org.apache.geronimo.samples.jaxrpc;

import java.math.BigDecimal;
import java.rmi.Remote;
import java.rmi.RemoteException;


public interface Converter extends Remote{
	
	public BigDecimal dollarToRupees(BigDecimal dollars) throws RemoteException;
	public BigDecimal rupeesToEuro(BigDecimal rupees) throws RemoteException;

}

Code Block
titleJAX-WS Converter SEI
borderStylesolid


package org.apache.geronimo.samples.jaxrpc;

import java.math.BigDecimal;
import javax.jws.WebService

@WebService(name = "Converter", targetNamespace = "http://org.apache.geronimo.samples.jaxws")
public interface Converter{
	
	public BigDecimal dollarToRupees(BigDecimal dollars);
	public BigDecimal rupeesToEuro(BigDecimal rupees);

}

The main differences that you can find here are:

  • Annotations - JAX-WS requires that all SEIs include the @WebService annotation
  • java.rmi.Remote - The JAX-RPC SEI extends the java.rmi.Remote interface. JAX-WS no longer requires this.

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)