RE: Getting started - parsing different types of messages and XML generation

"Gillen, Paul" <[email protected]> Fri, 05 Nov 2010 20:25:17 -0400
Newsgroups gmane.text.xml.xmlbeans.user
Message-ID <6A51CF4158562249906CB0F24DC99E4451EAC961FD@GATUCEXCH03ASV.nscorp.ad.nscorp.com>
axis2 + xmlbeans == the holy grail

let me know if you'd like an ant harness for that

good luck
=p=
________________________________
From: PhilNad214 PhilNad214 [[email protected]]
Sent: Friday, November 05, 2010 8:20 PM
To: [email protected]
Subject: Re: Getting started - parsing different types of messages and XML generation

A quick update re (2), the NPEs, my mistake - turns out I missed a NoClassDefFound exception in all the logging... once I saw that I searched deeper and found that although I am using a v2.5.0 xbean.jar, there was an older 2.2.0 jar in a subfolder from a previous axis2 project. That was causing runtime confusion, so resolving that has meant one less problem...

Cheers

On Fri, Nov 5, 2010 at 2:18 PM, PhilNad214 PhilNad214 <[email protected]<mailto:[email protected]>> wrote:
Hi, I'll start this by saying "I'm new to XBeans" :-)

I have a large .xsd file and I've successfully created a jar from it (pojos, document impl stuff, etc). The xsd represents a protocol for sending and receiving messages. But now that I've started trying to use it I have got stuck and not (yet) figured out answers via the getting started guide.

1) There are numerous examples of how to (eg) load an xml from disk:
[code]PurchaseOrderDocument poDoc = PurchaseOrderDocument.Factory.parse(purchaseOrder);[/code]
But this assumes you know what type of xml needs parsing (in this case a PurchaseOrder). What happens when you need to handle different types of xml message? I could parse the xml into a org.w3c.dom.Document object, then is there an XBeans-generated factory method which will examine that document and return me the correct pojo (eg a PurchaseOrder) for the document?

2) A lot of the documentation I've seen so far seems to involve the parsing of xml. But because I am implementing a request/response protocol, I also want to create pojos (from the generated jar) and convert to a org.w3c.dom.Document (or xml) for sending. How do I do this? Eg I am trying:
[code]RequestItemDocument rid = RequestItemDocument.Factory.newInstance();
or
impl.RequestedItemDocumentImpl ridi = new impl.RequestedItemDocumentImpl(SchemaType);[/code]
and guess I need to then call setters on these objects, but I'm not getting very far before I hit NPEs or similar (probably because my approach is wrong).
Anyway, is this the correct approach? And what next - get the Document via getDomNode(), etc?

Any suggestions (or pointers to the appropriate docs) welcome!
Thanks, Phil