Emil Genov bio photo

Emil Genov

Software developer living in Barcelona

LinkedIn Github Stackoverflow

Sometimes we need to use polymorphism and it is already supported by WSDL, so here is a little tricky explanation how to do this using XFire.

For example we have a basic type Party and two classes that extend it: Individual and Organisation. We define method in interface, that accepts Party, but we need to be possible to use Individual and Organisation objects with this method too. This is solved by adding following annotations to implementation of service:

@WebService(serviceName = "PartyProcessImpl", endpointInterface = "com.industria.PartyProcess")
@ServiceProperty(key=AegisBindingProvider.WRITE_XSI_TYPE_KEY, value="true"),
@ServiceProperty(key=AegisBindingProvider.OVERRIDE_TYPES_KEY, list={"com.party.Individual","com.party.Organisation"})
public class PartyProcessImpl implements PartyProcess {

basically in second @ServiceProperty annotations, we give a list of classes, that need to be check if override some of basic types that are used into WS interface.