Hi all,

I came up with the following behavior while preparing the exercises for the
SkillMatter ADB presentation.

Getting the pull parser and serializing gave me only the following.

<varString>Hello</varString>

While taking OMElement and serializing resulted in the following correct
serialization.

<ns1:myElement xmlns:ns1="http://soapinterop.org/types
"><varString>Hello</varString><varInt>12</varInt><varFloat>12.33
</varFloat></ns1:myElement>


Schema and the code are as attached with this mail.

Am I missing anything in the pullparser scenario?

Thanks,

~Thilina



<schema xmlns="http://www.w3.org/2001/XMLSchema"; xmlns:xsd="
http://www.w3.org/2001/XMLSchema";

xmlns:tns="http://soapinterop.org/types"; targetNamespace="
http://soapinterop.org/types";>

<import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>

<complexType name="SOAPStruct">

 <sequence>

  <element name="varString" type="xsd:string"/>

  <element name="varInt" type="xsd:int"/>

  <element name="varFloat" type="xsd:float"/>

 </sequence>

</complexType>

<element name="myElement" type="tns:SOAPStruct"/>

</schema>



           public static void main(String[] args) throws Exception {

                       MyElement elt = new MyElement();

                       SOAPStruct s = new SOAPStruct();

                       s.setVarString("Hello");

                       s.setVarInt(12);

                       s.setVarFloat(12.33F);

                       elt.setMyElement(s);



                       XMLStreamReader reader = elt.getPullParser(null);

                       OMElement omElt =

                             new
StAXOMBuilder(reader).getDocumentElement();

                       omElt.serialize(System.out);



                       OMFactory factory = new OMLinkedListImplFactory();

                       OMElement omElement = elt.getOMElement
(null,factory);

                       omElement.serialize(System.out);

           }


--
"May the SourcE be with u"
http://webservices.apache.org/~thilina/
http://thilinag.blogspot.com/
http://www.bloglines.com/blog/Thilina

Reply via email to