Codehaus XFire

Documentation

Quicklinks

Developers

Sponsors

Inheritance Support

XFire supports inheritance of POJOS in the Aegis binding. Enabling inheritance support in the Aegis binding requires two things.
1. You must enable the writing of xsi:type attributes. These attributes tell the XML consumer what type an element is.
2. You just supply XFire with a list of types which aren't referenced by your service class which need to be included in the WSDL.

Note: XFire does NOT support interface inheritance currently!!! This is because it would require support for multiple parent inheritance, which XML Schema restrictions can not do. While this could be supported via substition groups, we currently have not implemented that feature. If you wish to comment on interface inheritance support, please see issueXFIRE-556.

Note: If you're using JAXB, please see the JAXB 2.0 page for information on inheritance.

Here is an example of how to enable inheritance with the API:

ObjectServiceFactory serviceFactory = new ObjectServiceFactory();

// Create a properties hashmap
HashMap props = new HashMap();

// Enable the writing of xsi:type attributes
props.put(AegisBindingProvider.WRITE_XSI_TYPE_KEY, Boolean.TRUE);

// Supply a list of class names which need to be included in the wsdl.
ArrayList l = new ArrayList();
l.add(Employee.class.getName());
props.put(AegisBindingProvider.OVERRIDE_TYPES_KEY, l);

Service service = serviceFactory.create(InheritanceService.class, props);

getServiceRegistry().register(service);

NOTE: There is a bug in XBean which prevents the services.xml syntax from working correctly. You can use the SNAPSHOT version of XBean however which is located here.

If you were using services.xml, it would look something like this:

<service>
  ... define your normal configuration...
  <properties>
    <property key="writeXsiType">true</property>
    <property key="overrideTypesList">
      <list xmlns="">
        <value>com.acme.Employee</value>
      </list>
    </property>
  <properties>
</service>

or in spring:

<bean id="xfireExporter" class="org.codehaus.xfire.spring.remoting.XFireExporter">
...
        <property name="properties">
         <map>
             <entry key="writeXsiType">
                 <value type="java.lang.Boolean">true</value>
                 </entry>
             <entry key="overrideTypesList">
                 <list>
		 <value>my.package.Subclass1</value>
...
                 </list>
             </entry>
         </map>
        </property>
    </bean>