axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject [Axis2] [ADB] Generated code is flawed
Date Mon, 29 May 2006 07:36:49 GMT

I'm trying to convert an object to an OMElement, as described in the "ADB 
Howto" (

In fact, I'm doing exactly the same as in the code snippets in the howto 
-- using the same xml and code examples. I'm hitting a problem when I have 
created the OMElement using the StAXOMBuilder: the OMElement that is 
produced is *not* the top-level "myElement" element, but one of the 
sub-elements "varString".

I had to change both the XSD and the XML a bit in order to get the example 
correct and working:

<schema xmlns="" 
 <complexType name="SOAPStruct">
   <element name="varString" type="xsd:string"/>
   <element name="varInt" type="xsd:int"/>
   <element name="varFloat" type="xsd:float"/>
  <attribute name="foo"/>
 <element name="myElement" type="tns:SOAPStruct"/>

        xsi:schemaLocation=" test.xsd"

I have added a foo attribute to the toplevel element to further illustrate 
the problem.

I have pushed the xsd through XSD2Java, resulting in and
The first problem is that the foo attribute is not modeled anywhere in 
these two classes.

The following code reads the xml file, parses it to a MyElement instance, 
and then creates an OMElement of it, just as in the howto:

        XMLStreamReader reader = XMLInputFactory.newInstance().
                createXMLStreamReader(new FileReader("test.xml"));
        MyElement elt = MyElement.Factory.parse(reader);
        XMLStreamReader r = elt.getPullParser(null);
        OMElement omElt =  new StAXOMBuilder(r).getDocumentElement();

The output reads
        <varString xmlns="">Hello</varString>

What I expect to see (and actually need) is the full xml - not just the 
first sub element. 

Is the shown behaviour normal? If so, what do I need to do to get an 
OMElement that represents the full xml document?


Tom van den Berge
Java Architect
ACI Worldwide
Antwerpseweg 1
PO Box 867, 2800 AW
Gouda, the Netherlands
+31 182 691 917
View raw message