users@jaxb.java.net

[Follow-up] javax.xml.bind.UnmarshalException: unexpected element

From: Peizhao Hu <peizhao_at_itee.uq.edu.au>
Date: Thu, 03 May 2007 17:37:49 +1000

Hi,

I am sorry that I didn't verify the reverse binding before I post the error.

here I attached my code to do so as well, hope someone can give me some
direction about where I go wrong.

            // create a Marshaller and marshal to Document
            DocumentBuilderFactory dbf =
DocumentBuilderFactory.newInstance();
            dbf.setNamespaceAware(true);
            DocumentBuilder db = dbf.newDocumentBuilder();
            Document xmlDoc = db.newDocument();
            // Marshaller
            JAXBContext jc =
JAXBContext.newInstance("org.nicta.safe.network.ars.sensor.teds");
            Marshaller m = jc.createMarshaller();
            m.marshal(vtedsElement, xmlDoc);

            elt = xmlDoc.getDocumentElement();

            // Unmarshaller
            Unmarshaller u = jc.createUnmarshaller();
            JAXBElement<?> testElt = (JAXBElement<?>)u.unmarshal(elt);
            VTEDSType test = (VTEDSType)testElt.getValue();
            System.out.println("Testing object:
"+test.getBasicTEDS().getIdentification().get(0).getName());

These codes work fine locally, but when I used the same codes in my web
service, it failed.

regarding to previous error message, I just realize that the root
element should be "VTEDS" rather than "teds", but how come after SOAP
encoding, my xml element has been changed from VTEDS to teds?? btw, I
passed my VTEDS xml element as Object to the Web Service.

Please help~~~

-- 
regards;
Peizhao