Search code examples
javaxmlsoapdeserializationapache-axis

Deserialize SOAP Body generated by AXIS2


I am currently logging the XML generated by AXIS2 client code in my DB. Now i need to resend that XML request from the log. I have the XML Content that will come inside "SOAPBody" tag.

I have tried to using BeanUtil deserialize method. and even Axis2 object.factory.parse method, both do not work.


Solution

  • I ended up doing the following. If anyone looking to get he raw xml string from Axis2, you can use the following code.

        OMElement  ele= someElementObject.getOMElement(SomeElementObject.MY_QNAME, OMAbstractFactory.getOMFactory());
    
        String xmlString= ele.toStringWithConsume();
    

    where someElementObject is the xml tag pojo generated by Axis2 wsdl import wizard.

    To parse a string xml to Axis2 object, use the following code.

    SomeElementObject obj=SomeElementObject.Factory.parse(SOME_XML_STREAM);