Monday, October 6, 2008

Axiom - How to create a OMElement from a String

If someone is using Axis2's ServiceClient to send a request to a service they will have to deal with OMElements. That is because ServiceClient accepts the payload as a OMElement. Using Axiom API's to create this OMElement could be time consuming and may take several lines of code. Alternatively users could create this OMElement from a String as follows,

OMElement payload = AXIOMUtil.stringToOM("Hi! This is a sample Request.");

This utility method that comes with Axiom takes in a String as the argument and returns an OMElement.

4 comments:

Asanka said...

Very useful tip, it save my time.

matt said...

Thanks for the tip. Helped me to no end.

danzig666 said...

very useful, i spent a lot of time searching the way to transform string to omelement, because in the project that i´m working we have to deal with axis2, a dark world, thanks for your light ;-)

Glen Mazza said...

Many thanks, saved me a lot of time.