Tag Archives: jax-rpc

JAX-RPC Handlers – Why do we use it?

JAX-RPC Handlers – Why do we use it?

A handler is a component that can be associated with an entire Web service or with a particular Web service interface. JAX-RPC handlers allow you to intercept a SOAP message at various times during a service invocation. Several handlers can be combined into what is called a “handler chain”. We use the handlers in order to achieve the below

1. An authentucation component to process SOAP headers containing credentials
2. To encrypt meesagge before we can send it across the network
3. To show SOAP message content specific logging actions can be undertaken
4. To calculate the time taken to process a SOAP message

A handler is a java class that implements the javax.xml.rpc.handler.Handler interface. It has three methods (handleRequest, handleResponse, and handleFault) to handle SOAP requests, responses and faults, respectively.

public abstract interface javax.xml.rpc.handler.Handler extends java.lang.Object {
    public abstract boolean handleRequest(MessageContext context);
    public abstract boolean handleResponse(MessageContext context);
    public abstract boolean handleFault(MessageContext context);
    public abstract void init(HandleInfo info);
    public abstract void destory();
    public abstract QName[] getHeaders;
};


Differences between JAX-RPC and JAX-WS

by Kuldip Bajwa

The main differences between JAX-RPC and JAX-WS are listed below:

  • SOAP 1.2 as opposed to SOAP v1.1 (backward compatible).
  • JAX-RPC and JAX-WS support SOAP 1.1. JAX-WS also supports SOAP 1.2.
  • XML/HTTP
  • The WSDL 1.1 specification defined an HTTP binding, which is a means by which you can send XML messages over HTTP without SOAP. JAX-RPC ignored the HTTP binding. JAX-WS adds support for it.
  • WS-I’s Basic Profiles
  • JAX-RPC supports WS-I’s Basic Profile (BP) version 1.0. JAX-WS supports BP 1.1. (WS-I is the Web services interoperability organization.)
  • New Java features
    1. JAX-RPC maps to Java 1.4. JAX-WS maps to Java 5.0. JAX-WS relies on many of the features new in Java 5.0.
    2. Java EE 5, the successor to J2EE 1.4, adds support for JAX-WS, but it also retains support for JAX-RPC, which could be confusing to today’s Web services novices.
  • The data mapping model
    1. JAX-RPC has its own data mapping model, which covers about 90 percent of all schema types.Those that it does not cover are mapped to javax.xml.soap.SOAPElement.
    2. JAX-WS’s data mapping model is JAXB. JAXB promises mappings for all XML schemas and the current JAXB implementation is much quicker then its predecessors.
  • The interface mapping model
  • JAX-WS’s basic interface mapping model is not extensively different from JAX-RPC’s; however:
    1. JAX-WS’s model makes use of new Java 5.0 features.
    2. JAX-WS’s model introduces asynchronous functionality.
  • The dynamic programming model
    1. JAX-WS’s dynamic client model is quite different from JAX-RPC’s. Many of the changes acknowledge industry needs:
      1. It introduces message-oriented functionality.
      2. It introduces dynamic asynchronous functionality.
    2. JAX-WS also adds a dynamic server model, which JAX-RPC does not have
  • MTOM (Message Transmission Optimization Mechanism)
  • JAX-WS, via JAXB v2.0, adds support for MTOM, the new attachment specification. Microsoft never bought into the SOAP with Attachments specification; but it appears that everyone supports MTOM, so attachment interoperability should become a reality.
  • The handler model
    1. The handler model has changed quite a bit from JAX-RPC to JAX-WS.
    2. JAX-RPC handlers rely on SAAJ 1.2. JAX-WS handlers rely on the new SAAJ 1.3 specification
  • 15.The other main difference is that JAX-WS has performance advantages as it uses Asynchronous communication as opposed to synchronous in JAX-RPC.

Web services communication is defined in two design paradigms – namely JAX-RPC and JAX-WS.

In short:

  • JAX-WS allows for asynchronous communication as opposed to procedural blocking responses. Also the serialization and deserialization of XML data is done more efficiently and faster using the latest JAXB 2.0 implementation which is much more performing than the its predecessors.
  • JAX-WS is multi protocol compatible i.e. support of SOAP 1.1 and 1.2.
  • JAX-WS makes heavy of Java annotations as described by the JSR-181 specification which simplifies client implementation and readability.