Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

...

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 concrete method of a class, the Java Language Specification requires the system to data available may provide the parameter names from the source. The behavior of current Java compilers depends on whether you ask them to provide debug symbols. 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. abstract method, current Java compilers never provide the parameter names.

If there are no names, Simple creates ugly parameters named arg0, arg1, ... Further, if you forget to specify the SEI when creating a service, and only provide the SEB, Simple will see your concrete methods and assign actual parameter names (if you have debug symbols). If you client uses the SEI, they won't communicate. If you change your mind about debug symbols, you will change the contractThis 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 namesto give useful names, or be sure to provide the SEI to the ServerFactoryBean.

Simple and Data Bindings

...

Warning

There is a known issue for the JAXB data binding with POJO, please see Dan Kulp's comment in https://issues.apache.org/jira/browse/CXF-897Image Removed .
If you want to use JAXB binding you should use the JAX-WS Frontend. Mixing Simple Frontend and JAXB binding leads to problems. The article A simple JAX-WS service shows a code first JAX-WS service that is almost as easy to use as the Simple Frontend.