File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes XML and Related Technologies and the fly likes Convert axis generated java beans to xml Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Convert axis generated java beans to xml" Watch "Convert axis generated java beans to xml" New topic

Convert axis generated java beans to xml

Gurvinder Singh

Joined: Nov 10, 2008
Posts: 27
Hi all

I have a problem.
I have generated beans using axis2 wsdl2java technique.
I am populating these beans and then finally sending the complete bean containing all the other beans through webservice to the third party.

Now my requirement is to convert this big bean object to xml and keep it in the archive directory.
Now can someone tell me a nice way to convert my java bean object to xml.

Earlier i was using JAXB, but the third party was using axis2 and there was a mismatch while sending my request. So i had to switch to axis2 generated beans.
And now i dont have a parser option to parse my beans to xml.


g tsuji
Ranch Hand

Joined: Jan 18, 2011
Posts: 632
Would java.beans.XMLEncoder and XMLDecoder classes serve you any good?
Sathiesh Kumar Vs
Ranch Hand

Joined: Oct 24, 2010
Posts: 31
Sorry if I misunderstood your problem

I believe there should not be any problem depending on what the technology that you use and the service provider uses, as long as you both use the same Soap version. That is the core benefit of using a web service.

The beans generation may be different based on different web service frame works as the vendors would use their own binding mechanism, but JAXB is one standard binding technique that everyone wants to move to.

Still the XML generated out of the beans would be same, irrespective of the binding technique. If you still see some differences I think you can use custom handlers to tamper requests and responses

Thanks and Regards,
Gurvinder Singh

Joined: Nov 10, 2008
Posts: 27
I tried to use jaxb with my current ADB beans but when ever i try to create the marshaller, it says Object Factory not found, since adb beans does not have an object factory class in it.
I tried using XStream, but the final xml that i get, the elements are appended with some extra attributes. and the structure is also somewhat not the expected structure.
I tried with XMLEncoder too. seems it is also not sufficing my need.
I agree. Here's the link:
subject: Convert axis generated java beans to xml
jQuery in Action, 3rd edition