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);
The main file in all this is axis2. xml, which controls how the application deals with received messages. It defines message receivers and transport receivers, as well as defining transport senders and determining which modules are active.
Apache Axis2 is a SOAP processing engine and its main function is to deliver incoming SOAP messages into target applications, and in this context application is a Web service. This tutorial provides step by step guidance on how to create your first Hello World application.
(An OMElement is how the AXIs2 Object Model (AXIOM) represents an XML element.) Create the service descriptor, services. xml, which defines the class to be used by the service and the appropriate message receivers.
Just call yourObject.toString()
on OMElement
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With