Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8485141
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T20:33:33+00:00 2026-06-10T20:33:33+00:00

I am getting the following error when trying to convert xml response to java

  • 0

I am getting the following error when trying to convert xml response to java objects using jaxb

       javax.xml.bind.UnmarshalException: unexpected element (uri:"http://SOMETHING/doc/2006-03-01/", local:"Name"). Expected elements are <{}Name>,<{}IsTruncated>,<{}MaxKeys>,<{}Contents>,<{}Prefix>,<{}Marker>

Here is my XML :

       <ListBucketResult xmlns="http://something/doc/2006-03-01/">
           <Name>test2</Name>
            <Prefix/>
            <Marker/>
            <MaxKeys>3</MaxKeys>
            <IsTruncated>false</IsTruncated>
            <Contents>
                  <Key>metadata.xml</Key>
                  <LastModified>2012-09-04T08:29:36.000Z</LastModified>
                    <ETag>6b836fd43c402681506926b2248ec418</ETag>
                    <Size>3258</Size>
                   <StorageClass>STANDARD</StorageClass>
             </Contents>
          </ListBucketResult>

And my java object classes are something like this

            @XmlAccessorType(XmlAccessType.FIELD)
    @XmlType(name = "", propOrder = {
        "name",
        "prefix",
        "marker",
        "maxKeys",
        "isTruncated",
        "contents"
    })
    @XmlRootElement(name = "ListBucketResult")
    public class ListBucketResult {

@XmlElement(name = "Name", required = true)
protected String name;
@XmlElement(name = "Prefix", required = true)
protected String prefix;
@XmlElement(name = "Marker", required = true)
protected String marker;
@XmlElement(name = "MaxKeys")
protected int maxKeys;
@XmlElement(name = "IsTruncated")
protected boolean isTruncated;
@XmlElement(name = "Contents", required = true)
protected ListBucketResult.Contents contents;







         @XmlAccessorType(XmlAccessType.FIELD)
         @XmlType(name = "", propOrder = {
                "key",
                "lastModified",
                   "eTag",
                   "size",
                 "storageClass"
           })
          public static class Contents {

    @XmlElement(name = "Key", required = true)
    protected String key;
    @XmlElement(name = "LastModified", required = true)
    @XmlSchemaType(name = "dateTime")
    protected XMLGregorianCalendar lastModified;
    @XmlElement(name = "ETag", required = true)
    protected String eTag;
    @XmlElement(name = "Size")
    protected int size;
    @XmlElement(name = "StorageClass", required = true)
    protected String storageClass;

and finally my unmarshalling code is :

                          JAXBContext jc = JAXBContext.newInstance(ListBucketResult.class);
            Unmarshaller unmarshaller = jc.createUnmarshaller();
            unmarshaller.setEventHandler(new javax.xml.bind.helpers.DefaultValidationEventHandler());
               JAXBElement element = (JAXBElement) unmarshaller.unmarshal (inputStream);
            ListBucketResult customer = (ListBucketResult) element.getValue();

Could someone please let me know what am i doing incorrect ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T20:33:35+00:00Added an answer on June 10, 2026 at 8:33 pm

    The XML document contains elements which are part of the ‘http://something/doc/2006-03-01/’ namespace, but the annotated java class is not associated with that namespace. Try changing the @XmlType annotation to:

    @XmlType(name = "", namespace="http://something/doc/2006-03-01/", propOrder = { ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm getting the following error when trying to convert HL7v3 to HL7v2 The message
I'm getting the following error when trying to delete objects in my database while
I am getting the following error when trying to update an object using nhibernate.
I keep getting the following error when trying to parse some html using BeautifulSoup:
I'm getting the following error when trying to convert a varchar to datetime in
I am getting following error when I am trying to use Convert.FromBase64String The input
Help! I'm getting this error when trying to connect using JAX-WS webservice call: java.lang.NoClassDefFoundError:
Getting the following error when trying to start a session: Warning: session_start() [function.session-start]: Node
I am getting the following error when trying to save a file to disk:
I am getting the following error when trying to check in my code: $>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.