Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Try to gently scare people away from this

CXF includes a provides the 'simple frontend which builds services from reflection. This is in contrast to the JAX-WS frontend which requires you to annotate your web service classes or create a WSDL first. The simple frontend will use reflection to intelligently map your classes to a WSDL model. ' frontend to map Java APIs to and from WSDL models for web services. The simple front end is much like JAX-WS, however, where JAX-WS uses Java annotations to specify detailed configuration (and, indeed, requires a few), Simple is willing to map a 'naked' interface or class to a service, and respects some configuration options from .aegis.xml files shared with the Aegis data binding.

Note
titleMost Applications Should Use JAX-WS

The JAX-WS frontend is far more flexible than the Simple frontend. There are only two reasons to select Simple over JAX-WS:

  1. You must avoid the use of Java annotations. JAX-WS requires them, Simple does not.
  2. You want to have the absolutely smallest possible collection of additional dependencies. JAX-WS has more dependencies than Simple.

Other than these items, Simple has no advantages over JAX-WS. The implementation classes of JAX-WS in CXF are all subclasses of the implementation classes of Simple. In a 'simple' case, very nearly identical things happen in the Simple front end as in JAX-WS. CXF's extensions to JAX-WS, on the other hand, make it very 'simple' to use.

Simple Pitfall: Unreliable Parameter Names

The following pitfall exists, in fact, for both Simple and JAX-WS, but it is much easier to avoid it with JAX-WS.

The typical pattern of a web service is to define a Service Endpoint Interface and then create a class that implements that interface. When you own both ends of the process, you can simply use the SEI in both the server and the client.

The problem has to do with a quirk of Java reflection. If a program uses Java reflection to examine a function in a class, the Java Language Specification requires the system to provide the parameter names from the source. However, if a program uses reflection to look at an interface, the specification does not require parameter names. In practical terms, the usual Java compilers preserve interface parameter names only when compiling with debug information.

This leads to the following trap: If you turn debug information on and off when compiling the SEI, you will change the WSDL model. Incompatibly. If the server and client disagree on the compilation options, they can fail to communicate.

Thus, while JAX-WS @WebParam annotations may seem noisy and inconvenient, they are, in fact, ensuring that your service has a consistent contract.

If you choose to use the Simple front end, you will need to use parameter elements in a .aegis.xml file to specify the parameter names.

Simple and Data Bindings

By default CXF uses the JAXB databinding. If you are interested in a databinding which does not require annotations, please see the documentation on the Aegis Databinding (2.0.x).

...

This is a historical default, but often not what you will want, both due to the pitfall described above and the JAX-B issue described at the bottom of this page. If you choose to use the Simple front end, we recommend that you use the Aegis databinding.

ServerFactoryBean – Making a Service Endpoint

The ServerFactoryBean produces a Server instance for you. It requires a service class and an address to publish the service on. By creating a Server you'll have started your service and made it available to the outside world.

...

Your service is now started! You can access the wsdl at "http://localhost:9000/Hello?wsdl".

ClientProxyFactoryBean – Making a Client Proxy

You'll also want to create a client for your service. CXF includes a ClientProxyFactoryBean which will create a Java proxy for you from your interface which will invoke the service.

...