Versions Compared

Key

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

Excerpt

For CXF up to 2.0.x

Why Aegis?

Aegis is a fast, StAX based, data-binding that makes developing code first services as simply as possible. It is able to handle most classes and create intelligent schemas for them.

Features include:

  • No annotations are needed to expose classes
  • Support for interfaces
  • Support for collections including Maps
  • Support for a wide variety of datatypes

CXF 2.1 Documentation

There are some significant changes to Aegis in CXF 2.1. See Aegis (2.1).

Details on How It Works

This Page, which is a work in progress, explains some of the modularity of Aegis. You may find it helpful in understanding Aegis' behavior and in developing customizations.

...

Most people who use Aegis use the 'Simple' front end.

Code Block
xml
xml
  <simple:server id="pojoservice" serviceClass="demo.hw.server.HelloWorld" address="/hello_world">
  	<simple:serviceBean>
    		<bean class="demo.hw.server.HelloWorldImpl" />
  	</simple:serviceBean>
         <simple:dataBinding>
       <bean class="org.apache.cxf.aegis.databinding.AegisDatabinding" />
    </simple:dataBinding>
  <!-- Use this property only for XFire compatibility -- this version for 2.0.x ...
                 <property name="serviceConfigurations">
                     <list>
                       <bean class="org.apache.cxf.jaxws.support.JaxWsServiceConfiguration"/>
                       <bean class="org.apache.cxf.aegis.databinding.AegisServiceConfiguration"/>
                       <bean class="org.apache.cxf.service.factory.DefaultServiceConfiguration"/> 
                    </list>
                </property>
  -->
  </simple:server>
 </bean>

You can also use Aegis with JAX-WS. Here's a Spring configuration example for that.

Code Block
xml
xml
 <bean id="aegisBean" class="org.apache.cxf.aegis.databinding.AegisDatabinding" scope="prototype"/> 
 <bean id="jaxws-and-aegis-service-factory"
    class="org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean"
    scope="prototype"> 
        <property name="dataBinding" ref="aegisBean"/>
  <!-- Use this property only for XFire compatibility -- this version for 2.0.x ...
                 <property name="serviceConfigurations">
                     <list>
                       <bean class="org.apache.cxf.jaxws.support.JaxWsServiceConfiguration"/>
                       <bean class="org.apache.cxf.aegis.databinding.AegisServiceConfiguration"/>
                       <bean class="org.apache.cxf.service.factory.DefaultServiceConfiguration"/> 
                    </list>
                </property>
  -->
  <!-- Use this property only for XFire compatibility -- this version for 2.1
                 <property name="serviceConfigurations">
                     <list>
                       <bean class="org.apache.cxf.jaxws.support.JaxWsServiceConfiguration"/>
                       <bean class="org.apache.cxf.aegis.databinding.XFireCompatibilityServiceConfiguration"/>
                       <bean class="org.apache.cxf.service.factory.DefaultServiceConfiguration"/> 
                    </list>
                </property>
  -->
 </bean>

 <jaxws:endpoint id="my_service_endpoint" implementor="#my-service" address="/MyIndex">
  <jaxws:serviceFactory>
    <ref bean='jaxws-and-aegis-service-factory' />
  </jaxws:serviceFactory>
 </jaxws:endpoint>
 

Java configuration

Here's a Java configuration using the Simple front end.

...

Similarly, here is a client side using the simple front end. note the 'serviceClass', as always with . Note the use of the WSDL. Without the WSDL, the simple front end , should be a class, not an interface, since will try to learn
parameters names from Java reflection. As always, Java interfaces don't carry parameter names, and this results in names like 'arg0', 'arg1', etc, which don't match the service.

Code Block
java
java
import org.apache.cxf.aegis.databinding.AegisDatabinding;
import org.apache.cxf.frontend.ClientProxyFactoryBean;

ClientProxyFactoryBean factory = new ClientProxyFactoryBean();
factory.setServiceClass(serviceClassserviceInterfaceClassObject);
factory.setAddress("http://myhost/service");
factory.setWsdlLocation("http://myhost/service?wsdl");
factory.getServiceFactory().setDataBinding(new AegisDatabinding());
MyService client = (MyService) factory.create();

...

XFire had/has a different convention for generating namespace URI values from Java package names. It added an additional '/' character.
If you need to interoperate with XFire, you need to enable compatibility with this behavior. You enable this compatibility by adding
an additional service configuration class to your service configuration: XFireCompatibilityServiceConfiguration (in 2.0.x, AegisServiceConfiguration).
The spring example above shows the necessary configuration in a comment. For the client side in Java, you need to add the service configuration to the service factory
as follows:

Code Block
java
java
import org.apache.cxf.aegis.databinding.AegisServiceConfiguration;
// for 2.0.x
sf.getServiceFactory().getServiceConfigurations().add(0, new AegisServiceConfiguration());
// for 2.1
sf.getServiceFactory().getServiceConfigurations().add(0, new XFireCompatibilityServiceConfiguration());

...

Info
titleValidate your mapping!

You can find an XML Schema for Aegis mapping files here.
This version of the XML schema has comments to explain the bits and pieces.

Supported Types

  • Wiki MarkupBasic types: int, double, float, long, byte\[\], short, String, BigDecimal
  • Arrays
  • Collections - including Maps
  • Dates: java.util.Date, java.util.Calendar, java.sql.Timestamp, java.sql.Date, java.sql.Time
  • XML: org.w3c.dom.Docmument, org.jdom.Element, XMLStreamReader, Source
  • Complex types which are aggregations of the above

...