We are trying to adopt the latest Axis2 1.4 for dynamic invocation of web services. We need to be able to consume any web service from a user-provided WSDL. This means that we can not use data binding and code generation, and should work with the XML via DOM. We have existing code that uses W3C DOM interfaces such as org.w3c.dom.Element and we definitely want to stay within W3C object model. Axis2 OMElement does not extend Element so it's not usable directly. But I have found out that one can configure Axis2 to use DOM-compatible factories which would allow for casting between OMElement and Element.
I have coded a simple client for my BEA Echo service that creates an instance of org.apache.axiom.om.impl.dom.DocumentImpl and creates it's elements. I then cast the "method" element of this document to OMElement and pass it to ServiceClient.sendRecieve(). This works fine. The problem is that the result is returned as OMElement and if I try to cast it to Element I get java.lang.ClassCastException: org.apache.axiom.om.impl.llom.OMElementImpl. I looked through the code and it seems that Axis2 uses the default factory set to OMAbstractFactory to create objects when parsing XML, and by default that factory is set to org.apache.axiom.soap.impl.llom.soap11.SOAP11Factory via a constant. When I have tried overriding the default Axiom factory to use DOM-compliant factory as follows: System.setProperty(OMAbstractFactory.SOAP11_FACTORY_NAME_PROPERTY, "org.apache.axiom.soap.impl.dom.soap11.SOAP11Factory"); System.setProperty(OMAbstractFactory.SOAP12_FACTORY_NAME_PROPERTY, "org.apache.axiom.soap.impl.dom.soap12.SOAP12Factory"); I got the following exception in ServiceClient.sendReceive(): Exception in thread "main" java.lang.NullPointerException at org.apache.axis2.engine.AxisEngine.checkMustUnderstand(AxisEngine.java:7 9) at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:166) at org.apache.axis2.description.OutInAxisOperationClient.handleResponse(Out InAxisOperation.java:363) Looking at the code of org.apache.axiom.soap.impl.dom.SOAPHeaderImpl which seems to be returning a null iterator I see the following code public Iterator getHeadersToProcess(RolePlayer rolePlayer) { return null; // TODO: Implement this! } So, my question is, is it really true that W3C DOM-compliant factories are not completely implemented? Am I doing something wrong? If they are not implemented, I can try finishing them and submit a patch to JIRA, but I want to know if anyone is already working on this and what other pieces of functionality are not finished?