Working with JavaBeans

Working with strings, primitive data types, and arrays will only get you so far. Fortunately, Apache SOAP also includes support for JavaBeans and literal XML documents. According to the official JavaSoft documentation, a JavaBean is a reusable software component that can be visually manipulated within any building tool. More generally, however, a JavaBean is any Java class that follows the JavaBean naming convention. This convention requires that all accessible properties be made available via get/set methods. For example, a Color property must have a corresponding pair of getColor( )/setColor( ) methods. The only exceptions to this rule are boolean properties that require an is/set naming convention. The JavaBean convention also requires that you provide a zero-argument constructor.

By using Java reflection, a visual tool can determine the available Bean properties and make these properties available via easy-to-use text boxes or radio buttons. Along the same lines, Apache SOAP’s built-in BeanSerializer class can, by using reflection, transform any JavaBean into an XML element or receive an XML element and automatically build a corresponding JavaBean. This requires that both the client and service code have access to the class file for the JavaBean. The SOAP call does not actually download the code for the JavaBean, only the state of the JavaBean. Understanding how this works requires a more detailed understanding of Java-to-XML transformation and the ...

Get Web Services Essentials now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.