Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Table of Contents
maxLevel2
styleoutline

Overview

...

Info
titleNote...

This is work in progress.

CXF seeks to build the necessary infrastructure components for services. Goals for CXF are many and include:

  • Support for different bindings, including SOAP, REST, and Corba.
  • WS-* support , including WS-Addressing, WS-Policy, WS-ReliableMessaging, WS-Security, WS-ReliableMessagingSecurityPolicy, WS-SecureConverstation and WS-PolicyTrust (partial).
  • Support for multiple transports
  • Pluggable Data-bindings
  • Clean separation of front ends, like JAX-WS, from the core code.
  • High Performance
  • Embeddable
  • Intuitive & Easy to Use

The overall CXF architecture is primarily made up of the following parts:

  1. Bus: This is the backbone of the Apache CXF architecture.
  2. Front-ends: Front-ends provide a programming model to create services.
  3. Messaging & Interceptors: These provide the low level message and pipeline layer upon which most functionality is built.Front ends: Frontends provide a programming model to create services (e.g. JAX-WS).
  4. Services: Services host a Service model which is a WSDL-like model which that describes the service.
  5. Bindings: Bindings provide the functionality to interpret the protocol (i.e. SOAP, REST, Corba).
  6. Transports: Destinations and Conduits make up the transport abstraction that CXF uses to achieve transport neutrality.
  7. Endpoints: Under development

We'll take a look at each layer in turn and examine how they work together.

...

See Configuration of the Bus for an example of how to customise the bus by supplying your own bean configuration file and Configuration of Runtime Constructed Objects for more information on the special case of injecting into objects created by the runtime (as opposed to objects created by the IOC container itself).

Front-ends

Front-ends provide a programming model to interact with CXF. The primary front-end at the moment is JAX-WS. The JAX-WS implementation is cleanly separated from the rest of CXF – like the bindings and core. They provide functionality through interceptors that are added to Services and Endpoints. See also Front-ends.

JAX-WS Front-end

Under development

JAX-RS Front-end

Under development

Javascript Front-end

Under development

Simple Front-end

Under development

Messaging & Interceptors

CXF is built on a generic messaging layer comprised of Messages, Interceptors, and InterceptorChains. Interceptors are the fundamental unit of functionality. By dividing up how messages are processed and sent, this gives CXF a very flexible architecture. It can be reconfigured at any point in the processing. This also gives CXF the ability to pause & resume interceptor chains.

...

Code Block
java
java
public void handleMessage(Message m) {
  writeSoapEnvelopeStart();
  writeSoapBodyStart();

  // invoke next interceptor, which writes the contents of the SOAP Body
  m.getInterceptorChain().doIntercept(m);
  writeSoapBodyEnd();

  writeSoapEnvelopeEnd();
}

Transports

CXF includes its own transport abstraction layer to hide transport specific details from the binding and front end layers.

Conduits

Conduits provide the basis for outgoing message sending. A Conduit is created from a ConduitInitiator. Sending a message is a multistep pocess:

  1. Call conduit.prepare(message): this starts the message sending. At this point a Conduit may initiate a connection and set the OutputStream for the outgoing message.
  2. Writing of the actual message to the OutputStream
  3. Call to conduit.close(message): this closes and disposes of any existing resources for the message sending.
    A message sender may also register a MessageObserver with the Conduit. If the Conduit is synchronous, the MessageObserver will be notified once a response has been received.

Destinations

Destinations are the basis for receiving incoming messages. A destination is created from a DestinationFactory:

...


DestinationFactoryManager dfManager = bus.getExtension(DestinationFactoryManager.class);

// Find a DestinationFactory for the SOAP HTTP transport
DestinationFactory df = dfManager.getDestinationFactory("http://schemas.xmlsoap.org/wsdl/soap/http");

// TODO: outline building of EndpointInfo
EndpointInfo endpointInfo = ...;
Destination destination = df.getDestination(endpointInfo);

MessageObservers can then be registered with Destinations. These listen for incoming messages:

...


MessageObserver myObserver = ...;
destination.setMessageObserver(myObserver);

The most common MessageObserver used in CXF is the ChainInitiationObserver. This takes the incoming message, creates a message Exchange & PhaseInterceptorChain, then starts the chain.

Data Bindings

...

The Service Model

The Service model is the representation of a service within CXF. It is made up of two parts. First there is the ServiceInfo which contains a WSDL-like model of the service and its operations, bindings, and endpoints. Second, there is the Service itself, which contains the ServiceInfo, data-binding information, service interceptors, service properties, and more.

...

Code Block
ServiceInfo
+-Interface: InterfaceInfo
| +-Operations: Collection<OperationInfo>
| | +- Input: MessageInfo
| | +- Output: MessageInfo
| | +- Faults: Collection<MessageInfo>
+-Bindings: Collection<BindingInfo>
| +-Operations: Collection<BindingOperationInfo>
+-Endpoints: Collection<EndpointInfo>

Data Bindings

Data Bindings implement the mapping between XML and Java. Data bindings convert data to and from XML, produce XML schema, and provide support for wsdl2java code generation. Not all data bindings support all of this functionality. At very least, a data binding must provide the data conversion. See Data Binding Architecture for details.

Protocol Bindings

Bindings provide ways to map concrete formats & protocols on top of transports. A binding contains two main parts, a BindingFactory and a Binding. A BindingFactory builds a Binding from the service model's BindingInfo. The binding contains interceptors specific to the binding and also implements the createMessage() method, which creates a Message implementation specific for that binding.

...

  1. StaxInInterceptor: Creates an XMLStreamReader from an incoming InputStream
  2. ReadHeadersInterceptor: Reads the headers into the SoapMessage
  3. MustUnderstandInterceptor: Checks the MustUnderstand attributes of all the headers against all the SoapInterceptor's getUnderstoodHeaders method.
  4. SoapOutInterceptor:

XML Binding

Endpoints

Front-ends

Frontends provide a programming model to interact with CXF. The primary frontend at the moment is JAX-WS. The JAX-WS implementation is cleanly separated from the rest of CXF – like the bindings and core. They provide functionality through interceptors that are added to Services and Endpoints.

...

Transports

CXF includes its own transport abstraction layer to hide transport specific details from the binding and front end layers.

Conduits

Conduits provide the basis for outgoing message sending. A Conduit is created from a ConduitInitiator. Sending a message is a multistep pocess:

  1. Call conduit.prepare(message): this starts the message sending. At this point a Conduit may initiate a connection and set the OutputStream for the outgoing message.
  2. Writing of the actual message to the OutputStream
  3. Call to conduit.close(message): this closes and disposes of any existing resources for the message sending.
    A message sender may also register a MessageObserver with the Conduit. If the Conduit is synchronous, the MessageObserver will be notified once a response has been received.

Destinations

Destinations are the basis for receiving incoming messages. A destination is created from a DestinationFactory:

Code Block
java
java

DestinationFactoryManager dfManager = bus.getExtension(DestinationFactoryManager.class);

// Find a DestinationFactory for the SOAP HTTP transport
DestinationFactory df = dfManager.getDestinationFactory("http://schemas.xmlsoap.org/wsdl/soap/http");

// TODO: outline building of EndpointInfo
EndpointInfo endpointInfo = ...;
Destination destination = df.getDestination(endpointInfo);

MessageObservers can then be registered with Destinations. These listen for incoming messages:

Code Block
java
java

MessageObserver myObserver = ...;
destination.setMessageObserver(myObserver);

The most common MessageObserver used in CXF is the ChainInitiationObserver. This takes the incoming message, creates a message Exchange & PhaseInterceptorChain, then starts the chain.

Endpoints

Putting it all Together

A JAX-WS example

...