J2XB Axis2 Module - Supported Types and Annotations

The J2XB library is designed to map Java Objects to XML data. The J2XB Axis2 Module maps method parameters and exceptions to XML, and as such suppports most of the capabilities of J2XB with some exceptions.

This section lists the support of a J2XB Axis2 Module for service creation - what J2XB annotations are supported and what types are supported.

Annotations Supported on the Service Class Method Parameters

The service class can accept annotations on a method or on the method parameters (Annotating the method is understood as annotating the return parameter of the method). The supported annotations are:

The MOWebParam annotation

The MOWebParam annotation allows to control some aspects of the web method parameter, match line the MOProperty annotation for a Bean property. It allows to define, for a web method parameter, the following:

  • xmlName - the name of the parameter in the XML representation.
  • xmlOptional - is the parameter optional
  • isXmlAttribute - should the parameter be possitioned as an attribute instead of an XML element
  • defaultValue - default value for the parameter, if the parameter value is not specified in a Web Service call.

The MOSeeAlso and MORegisterPropertyEditor(s) annotations

A Web Service using the J2XB module is itself scaned for those two annotations to register additional types with the J2XB system.

The MOSeeAlso annotation allows to register a number of beans with the J2XB system, mainly usefull when bean inheritence is used in the service (e.g. some service parameters are beans that can accept inherited beans as well).

The MORegisterPropertyEditor and MORegisterPropertyEditors annotations allows to register additional J2XB property editors - see the Types section.

Types supported for a Web Service Service Class

The J2XB module allows to use any Java type as a method parameter (or a method return value) given that one of the following applies -

  • The type is any built-in Java type that is supported out of the box with J2XB (that is, there is a built-in property editor registered for it). See the list of built-in types in the Types section.
  • The typs is any Java class mapped using the J2XB annotations - it is mapped using the MOPersistentBean annotation.
  • The type is any other Java class for which an appropriate property editor was registered using the xmlBindingModel.getPropertyEditorRegistry().registerPropertyEditor(propertyClass, propertyEditorClass); fragment or using the MORegisterPropertyEditor(s) annotations.
  • The type is a Set , List or Array of any of the above types.

Support for Exceptions

The J2XB Axis2 module supports exceptions and exception mapping to web services fault messages. Java built-in exceptions are automatically mapped while J2XB allows to map additional exception types.

The Throwable.message property is automatically mapped. The Throwable.stackTrace property can be mapped, if required. Note that mapping the stack trace can be considered a security risk and is disabled by default. To activate the stack trace mapping, use the J2XB_MAP_EXCEPTION_TRACE parameter in the services.xml file.

For instance, for the services.xml example in the introduction, we add

<service name="StockQuoteService" scope="application" targetNamespace="http://quickstart.samples/">
    Stock Quote Service
  <module ref="J2XB"/>
  <schema schemaNamespace="http://quickstart.samples/xsd"/>
  <parameter name="ServiceClass">samples.quickstart.service.pojo.StockQuoteService</parameter>
  <parameter name="J2XB_MAP_EXCEPTION_TRACE">true</parameter>