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

  • Home
  • SEARCH
  • 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 7588193
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T19:51:46+00:00 2026-05-30T19:51:46+00:00

I’m putting together a Java client for Bing Translate, using their REST API. I

  • 0

I’m putting together a Java client for Bing Translate, using their REST API. I can authenticate with OAuth and run translations with no problem, unmarshalling those simple String responses into JAXB objects with no problem.

However, when it comes to more complex types, I’m struggling to work out why I’m constantly getting a null value on the field of my Java object. The response I get from the service is:

  <ArrayOfstring
    xmlns="http://schemas.microsoft.com/2003/10/Serialization/Arrays"
    xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
    <string>ar</string>
    <string>bg</string>
    <string>ca</string>
    <string>zh-CHS</string>
    <string>zh-CHT</string>
</ArrayOfstring>

I’m unmarshalling the object using the following method:

@SuppressWarnings("unchecked")
  public static <T extends Object> T unmarshallObject(Class<T> clazz, InputStream stream)
  {
    T returnType = null;

    try
    {
      JAXBContext jc = JAXBContext.newInstance(clazz);
      Unmarshaller u = jc.createUnmarshaller();

      returnType = (T) u.unmarshal(stream);
    } catch (Exception e1)
    {
      e1.printStackTrace();
    }

    return returnType;

  }

Which works fine for simple objects, so I suspect the problem lies within my annotations for the complex object I’m trying to generate. The code for that is:

package some.package; 
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAnyElement;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlElements;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.XmlValue;

@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name="ArrayOfstring", namespace="http://schemas.microsoft.com/2003/10/Serialization/Arrays")
public class ArrayOfString implements Serializable
{

  @XmlElement(name="string", namespace="http://schemas.microsoft.com/2003/10/Serialization")
  private List<String> string;

  public List<String> getString()
  {
    return string;
  }

  public void setString(List<String> strings)
  {
    this.string = strings;
  }

}

In desperation, I replaced the @XmlElement(name=”string”) with @XmlAnyElement and I got a List of Strings back, but no values.

So, my question is – what needs to change for the above XML to be interpretted correctly, and more importantly why?

  • 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-05-30T19:51:48+00:00Added an answer on May 30, 2026 at 7:51 pm

    In your example, your string elements actually belong to the http://schemas.microsoft.com/2003/10/Serialization/Arrays namespace.

    Your annotation says you expect the http://schemas.microsoft.com/2003/10/Serialization namespace.

    Try

    @XmlElement(name="string",
        namespace="http://schemas.microsoft.com/2003/10/Serialization/Arrays")
    private List<String> string;
    

    instead.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I have thousands of HTML files to process using Groovy/Java and I need to
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a jquery bug and I've been looking for hours now, I can't
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
Does anyone know how can I replace this 2 symbol below from the string

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.