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 [EMAIL PROTECTED] So I think the steps to get it working are:
1) get a hold of the [EMAIL PROTECTED] 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
On 2/17/06, Jerome Magnet <[EMAIL PROTECTED]> wrote:
> Edward Frederick <epfrederick <at> gmail.com> writes:
>
> >
> > Jerome,
> >
> > Re: Using the *Document Factories: It's kind of a subtle thing, but
> > the compiled objects represent the -contents- of the types, not the
> > elements themselves. You need to use the document factory because
> > you're parsing a document that has an instance of a complex type as
> > its document element, not a document that represents the contents of
> > an instance of a complex type. I even confuse myself (if I'm not
> > already off base).
> >
> > My guess is that the header within a header thing is killing
> > you--hdrT's factory is parsing the entire soap header, not your header
> > within that header. They have the same name, so it looks like the
> > factory isn't complaining about the contour.
> >
> > Maybe try:
> >
> > HeaderT hdrT = HeaderT.Factory.parse(soapHdr.getDomNode().getFirstChild());
> >
> > Ed
> >
> > On 2/17/06, Jerome Magnet <jeromem <at> nortel.com> wrote:
> > > I am trying to use XML beans in doing simple parsing and data retieval.
> > > I successfully generated all the Java classes for two schemas. The parsing
> of
> > > an XML document built with these two embedded XML from two different
> namespaces
> > > seems to be working well. But, I can't retrieve the simple element values
> using
> > > the get methods. I was able to do it for a simple XML from one
> > > schema/namespace. Also, I noticed that it only works if you parse from the
> > > document class ("Element"Document.Factory.parse()). And, it does not work
> > > if
> > > you parse directly with the element class ("Element".Factory.parse()). I
> could
> > > not find out why in the user guides?
> > >
> > > thanks to help identify the simple thing I am not seeing!
> > > Here are the details below:
> > >
> > > I use Win2000 with latest XML Beans 2.
> > >
> > > The following is my code snipet:
> > > 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());
> > > System.out.println("\nRequest header fragment as Xbean
> toStr:\n"+hdrT.toString
> > > ());
> > > System.out.println("hdrT.activity="+hdrT.getActivityName());
> > >
> > > The following is the output from the above code:
> > > Request header fragment as Xbean toStr:
> > > <soap:Header xmlns:soap="http://www.w3.org/2003/05/soap-envelope"
> > > xmlns="tmf854.v1">
> > > <header>
> > > <activityName>getSNCsByUserLabel</activityName>
> > > <msgName>getSNCsByUserLabel</msgName>
> > > <msgType>REQUEST</msgType>
> > > <replyToURI>MTOSI/CramerOS</replyToURI>
> > > <correlationId>1234</correlationId>
> > > <communicationPattern>SimpleResponse</communicationPattern>
> > > <communicationStyle>MSG</communicationStyle>
> > > <timestamp>20051004140259</timestamp>
> > > </header>
> > > </soap:Header>
> > > hdrT.activity=null
> > >
> > > Notice that I have two schemas 1:SOAP-ENV and 2:MyOwn (default namespace)
> > > I can't get to any of the <header> element values (getActivityName
> > > returned
> > > null)
> > >
> > > Here is my own schema
> > > <?xml version="1.0" encoding="UTF-8"?>
> > > <!-- TMF854 Version 1.0 - Copyright TeleManagement Forum 2005 -->
> > > <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> > > targetNamespace="tmf854.v1" xmlns="tmf854.v1"
> > > attributeFormDefault="unqualified" elementFormDefault="qualified">
> > > <!-- ======= All includes ======= -->
> > > <xsd:include schemaLocation="headerVendorExtensions.xsd"/>
> > > <!-- ======== Global Type Declarations ========= -->
> > > <xsd:simpleType name="ActivityName_T">
> > > <xsd:restriction base="xsd:string">
> > > <xsd:pattern value="\w*"/>
> > > </xsd:restriction>
> > > </xsd:simpleType>
> > > ...
> > > <xsd:element name="header" type="Header_T"/>
> > > <xsd:complexType name="Header_T">
> > > <xsd:all>
> > > <xsd:element name="activityName" type="ActivityName_T">
> > > </xsd:element>
> > > ...
> > > </xsd:complexType>
> > > </xsd:schema>
> > >
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: user-unsubscribe <at> xmlbeans.apache.org
> > > For additional commands, e-mail: user-help <at> xmlbeans.apache.org
> > >
> > >
> >
>
> Ed,
>
> Thanks for following up on my stumbles using XML Beans.
> I tried your sugestion without luck. I spent a long time on this issue with
> XML
> Beans. I tried with the body part of my soap envelope, which is a complex of a
> single simple type element (string). There is no element name conflict as you
> mentioned, which does not really exists as from two namespaces; soap:Header
> and
> [EMAIL PROTECTED] So, even with the soap:body element retrieval it does not
> work!
>
> I am very confused. It I do a dump of the two headers:.
> soapHdr.dump();
> hdrT.dump();
>
> I get the following:
> ROOT (USER) <mark>[0] (DocumentXobj)
> ELEM soap:[EMAIL PROTECTED]://www.w3.org/2003/05/soap-envelope (USER)
> (ElementXobj)
> ATTR xmlns:[EMAIL PROTECTED]://www.w3.org/2000/xmlns/ Value
> ( "http://www.w3.org/2003/05/soap-envel..." ) (AttrXobj)
> ATTR [EMAIL PROTECTED]://www.w3.org/2000/xmlns/ Value( "tmf854.v1" )
> After
> ( "\n\t" ) (AttrXobj)
> ELEM soap:[EMAIL PROTECTED]://www.w3.org/2003/05/soap-envelope Value(
> "\n\t\t"
> TEXT[3] ) (USER) After( "\n\t" TEXT[2] ) *:R:<cur>[0] (ElementXobj)
> ELEM [EMAIL PROTECTED] Value( "\n\t\t\t" TEXT[4] ) After( "\n\t" TEXT
> [2] ) (ElementXobj)
> ELEM [EMAIL PROTECTED] Value( "getSNCsByUserLabel" TEXT[18] )
> After( "\n\t\t\t" TEXT[4] ) (ElementXobj)
> ELEM [EMAIL PROTECTED] Value( "getSNCsByUserLabel" TEXT[18] ) After
> ( "\n\t\t\t" TEXT[4] ) (ElementXobj)
> ELEM [EMAIL PROTECTED] Value( "REQUEST" TEXT[7] ) After( "\n\t\t\t"
> TEXT[4] ) (ElementXobj)
> ELEM [EMAIL PROTECTED] Value( "MTOSI/CramerOS" TEXT[14] ) After
> ( "\n\t\t\t" TEXT[4] ) (ElementXobj)
> ELEM [EMAIL PROTECTED] Value( "1234" TEXT[4] ) After
> ( "\n\t\t\t" TEXT[4] ) (ElementXobj)
> ELEM [EMAIL PROTECTED] Value( "SimpleResponse" TEXT
> [14] ) After( "\n\t\t\t" TEXT[4] ) (ElementXobj)
> ELEM [EMAIL PROTECTED] Value( "MSG" TEXT[3] ) After
> ( "\n\t\t\t" TEXT[4] ) (ElementXobj)
> ELEM [EMAIL PROTECTED] Value( "20051004140259" TEXT[14] ) After
> ( "\n\t\t" TEXT[3] ) (ElementXobj)
> ELEM soap:[EMAIL PROTECTED]://www.w3.org/2003/05/soap-envelope Value(
> "\n\t\t" )
> After( "\n" ) (ElementXobj)
> ELEM [EMAIL PROTECTED] Value( "\n\t\t\t" ) After( "\n\t" )
> (ElementXobj)
> ELEM [EMAIL PROTECTED] Value( "aUserLabel" ) After( "\n\t\t" )
> (ElementXobj)
>
> ROOT (USER) *:R:<cur>[0] (DocumentXobj)
> ELEM soap:[EMAIL PROTECTED]://www.w3.org/2003/05/soap-envelope Value(
> "\n\t\t" )
> (ElementXobj)
> ELEM [EMAIL PROTECTED] Value( "\n\t\t\t" ) After( "\n\t" ) (ElementXobj)
> ELEM [EMAIL PROTECTED] Value( "getSNCsByUserLabel" ) After
> ( "\n\t\t\t" ) (ElementXobj)
> ELEM [EMAIL PROTECTED] Value( "getSNCsByUserLabel" ) After
> ( "\n\t\t\t" ) (ElementXobj)
> ELEM [EMAIL PROTECTED] Value( "REQUEST" ) After( "\n\t\t\t" )
> (ElementXobj)
> ELEM [EMAIL PROTECTED] Value( "MTOSI/CramerOS" ) After( "\n\t\t\t" )
> (ElementXobj)
> ELEM [EMAIL PROTECTED] Value( "1234" ) After( "\n\t\t\t" )
> (ElementXobj)
> ELEM [EMAIL PROTECTED] Value( "SimpleResponse" ) After
> ( "\n\t\t\t" ) (ElementXobj)
> ELEM [EMAIL PROTECTED] Value( "MSG" ) After( "\n\t\t\t" )
> (ElementXobj)
> ELEM [EMAIL PROTECTED] Value( "20051004140259" ) After( "\n\t\t" )
> (ElementXobj)
>
> So, it seems that the structure is all there. But, how can I access the
> <header> element values using the XML beans methods?
>
> Jerome
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]