Axis2 object to xml
Asked Answered
C

1

10

I have an Axis2 Object returned from my Java code. How can I convert that object to XML or output it as XML in the console? I know there is lots of 3rd party libraries available to serialize objects to XML - but how to do it with the Axis2?


Update: From this link I found the solution. One needs to get an OMElement like this:

OMElement omElement = sampleElement1
          .getOMElement(SampleElement1.MY_QNAME, OMAbstractFactory.getOMFactory()); 
String omElementString = omElement.toStringWithConsume();
System.out.println("XML String ==> " + omElementString);
Cotemporary answered 2/11, 2010 at 5:7 Comment(1)
I referred this URL : wso2.org/library/2068 ... and i found the solution ..... we need to get OMElement using the getOMElement method OMElement omElement = sampleElement1.getOMElement(SampleElement1.MY_QNAME, OMAbstractFactory.getOMFactory()); String omElementString = omElement.toStringWithConsume(); System.out.println("XML String ==> " + omElementString);Cotemporary
M
2

Just call yourObject.toString() on OMElement

Mcguinness answered 14/9, 2012 at 13:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.