Hi Jerome The SOAP envelope schema simply says that the SOAP Header element can contain "anything". Generated XmlObjects do not provide getters and setters for "anything" (this is under discussion - there are some technical details which make it tricky - for instance you can have more than one "anything") so the current recommended approach is to rely on the XmlCursor.
Detail on how to navigate around any XML document using the XmlCursor are given at http://xmlbeans.apache.org/docs/2.0.0/guide/conNavigatingXMLwithCursors. html (in general http://xmlbeans.apache.org/documentation/index.html is a good place to start). In your case you can parse the SOAP information and get the SOAP header as you are doing: File msgFile = new File(reqMsgDocFilename); EnvelopeDocument soapEnvDoc = EnvelopeDocument.Factory.parse(msgFile); Envelope soapEnv = soapEnvDoc.getEnvelope(); Header soapHdr = soapEnv.getHeader(); Then you can get an XmlCursor positioned just before the start token of the SOAP header by doing: XmlCursor cursor1 = soapHdr.newCursor(); Then navigate to the SOAP Header's first child (which is your <header> element): cursor1.toFirstChild(); (If you had a different setup there are many other APIs available on XmlCursor - e.g. you can navigate specifically to a child with a given QName using toChild(QName)). Then get an XMLStreamReader XmlStreamReader rdr = cursor1.newXMLStreamReader(); or you could get the text itself as a String String internalHdrAsString = cursor1.xmlText()); whichever you like. Then you can parse (I've used the reader below - you could just as well pass in the String): tmf854.v1.HeaderDocument internalHdrElement = tmf854.v1. HeaderDocument.Factory.parse(rdr); After this you should be able to do internalHdrElement.getActivityName(). (You already have elementFormDefault="qualified" for that schema - so it's correct that your instance doc refers to the internal elements using their namespaces). And don't forget to call cursor1.dispose() at the end. Not sure why the approach using DOM doesn't work - I don't know a lot about that part of the code - but one of the reasons for XmlCursor is to be there is specifically to help solve this kind of issue - so the approach above should work. The only tricky thing with XmlCursor is to be sure exactly which token the cursor is pointing to at any point in time - the link I gave above and this one (http://xmlbeans.apache.org/docs/2.0.0/guide/conUnderstandingXMLTokens.h tml) should help with this. Cheers, Lawrence > -----Original Message----- > From: news [mailto:[EMAIL PROTECTED] On Behalf Of Jerome Magnet > Sent: Friday, February 17, 2006 7:41 PM > To: [email protected] > Subject: Re: XML Beans usage question > > > > Edward Frederick <epfrederick <at> gmail.com> writes: > > > > > You're close--I think there's two pieces to the problem. > > > > On your dump of the soap header, the <cur> is the soap:Header and not > > your header <at> tmf854.v1. So I think the steps to get it working are: > > > > 1) get a hold of the header <at> tmf854.v1 node (does dumping > > getFirstChild() give you this as <cur>?) > > > > 2) parse it with the HeaderT document factory. > > > > HeaderTDocument encl = HeaderTDocument.Factory.parse(yourHeaderDomNode); > > HeaderT hdr = encl.getHeaderT(); > > > > Good Luck, > > > > Ed > > > > Ed, > > First, what is it with this error of top-posting? I have never such stupid > thing! > > Now the dump was with the original: > > HeaderT hdrT = HeaderT.Factory.parse(soapHdr.getDomNode()); > > If I do down one level by adding .getFirstChild() I get an empty dump as > followed: > > ROOT Value( "\n\t\t" ) (USER) *:R:<cur>[0] (DocumentXobj) > > And if I do as you mention below > > File msgFile = new File(reqMsgDocFilename); > EnvelopeDocument soapEnvDoc = EnvelopeDocument.Factory.parse(msgFile); > Envelope soapEnv = soapEnvDoc.getEnvelope(); > Header soapHdr = soapEnv.getHeader(); > HeaderT hdrT = > HeaderT.Factory.parse(soapHdr.getDomNode().getFirstChild()); > HeaderDocument hdrDoc = HeaderDocument.Factory.parse(soapHdr.getDomNode > ().getFirstChild()); > HeaderT hdr = hdrDoc.getHeader(); > System.out.println("\nRequest header fragment as Xbean > toStr:\n"+hdrDoc.toString > ()); > System.out.println("hdrT.activity="+hdr.getActivityName()); > soapHdr.dump(); > hdr.dump(); > > I get an exception: > org.apache.xmlbeans.XmlException: error: The document is not a > [EMAIL PROTECTED]: no document element > at org.apache.xmlbeans.impl.store.Locale.verifyDocumentType > (Locale.java:452) > at org.apache.xmlbeans.impl.store.Locale.autoTypeDocument > (Locale.java:357) > at org.apache.xmlbeans.impl.store.Locale.parseToXmlObject > (Locale.java:1384) > at org.apache.xmlbeans.impl.store.Locale.parseToXmlObject > (Locale.java:1363) > at org.apache.xmlbeans.impl.schema.SchemaTypeLoaderBase.parse > (SchemaTypeLoaderBase.java:370) > at org.tmforum.mtosi.HeaderDocument$Factory.parse(Unknown Source) > at Main.testXMLBeans(Main.java:65) > at Main.main(Main.java:32) > > Thanks, > Jerome > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] _______________________________________________________________________ Notice: This email message, together with any attachments, may contain information of BEA Systems, Inc., its subsidiaries and affiliated entities, that may be confidential, proprietary, copyrighted and/or legally privileged, and is intended solely for the use of the individual or entity named in this message. If you are not the intended recipient, and have received this message in error, please immediately return this by email and then delete it. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

