ADB databinding in axis2 uses the ADBDatasource to return the OMElement.
Currently ADBDatasource getReader and serialize methods are like this. public abstract void serialize(XMLStreamWriter xmlWriter) throws XMLStreamException; public XMLStreamReader getReader() throws XMLStreamException { return bean.getPullParser(parentQName); } When we want to serialize the xml stream directly to transport we use serialize method and the getReader is used in building the OMElemnet. Specially Rampart module always build the OMElement and hence call for getReader() method. The serialize method is worked fine and it is the well tested method in ADB and the getReader method which uses the ADBXmlStremReader has some issue regarding extension and binary handling. To solve this problem I wrote OMElmentStreamWriter [1] which build the OMElement from the writer. So now the getReader method looks like this. It use the serialize method to create the OMElement. public XMLStreamReader getReader() throws XMLStreamException { OMElementStreamWriter omElementStreamWriter = new OMElementStreamWriter(); serialize(omElementStreamWriter); return omElementStreamWriter.getOMElement().getXMLStreamReader(); } this method perfectly works except the following two problems. 1. It is bit in efficient OMElementStreamWriter first creates the OMElement and then it is used to get the reader and again buid the OMElement. To solve that either we can introduce a method to OMDataSource to directly return the OMElement or AXIOM it self can use the above writer to build the OMElement using the serilize method. 2. problems with the MTOM This writer is not aware mtom. so it always serialize it as base64binary. To fix this problem we can test for this pirticular writer in ADB generated code (using instanceof or using a property) and set the data handler to the element using a special method. So this way we can create an OMElement which has a datahandler object in it. in ADB bean class if (writer instanceof OMElementStreamWriter){ (OMElementStreamWriter)writer).setDataHandler(dataHandler); } in OMElementStreamWriter public void setDataHandler(DataHandler dataHandler){ OMText omText = omFactory.createOMText(dataHandler,true); currentOMElement.addChild(omText); } would this solve our problem? And can someone has a better knowledge with Axiom comment on these? The main advantage ADB has from this is to use the well tested serialize method and hence keep one method to serailize the bean. thanks, Amila. [1] https://svn.apache.org/repos/asf/webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/writer/OMElementStreamWriter.java -- Amila Suriarachchi, WSO2 Inc.