We all started somewhere! Share your experience on the Get Advice: Let's Get Started Sweepstakes thread and be entered to win a $100 credit on your Constant Contact account.

Problem marshalling API response using RestEasy

Occasional Participant

Problem marshalling API response using RestEasy

 Hi All,

I am trying to use the Constant Contact API from within Java. I am using RestEasy in combination with JAXB. I am able to send the request using ProxyFactory and I am trying to extract my JAXB Object by using content.getJAXBObject(ContactList.class);

My ContactList class is a JAXB annotated class, namespace is properly set. It has a bunch of elements and one attribute.When I try to access

my ContactList instance only the attribute is properly populated, all elements are still null. Any ideas why this seems to only partially unmarshall?

Here's my ContactList class:

@XmlRootElement(name = "ContactList", namespace = "{namespace}")


public class ContactList {


   public String id;


   @XmlElement  (name="Name")

   public String name;



Here's the Service that I am calling using ProxyFactory

public interface ContactListService {




  public Entry getListById(@PathParam("id") String id);



and here's the call to the proxy:

ContactListService  client = ProxyFactory.create(ContactListService

.class, API_BASE + contactListResource, clientExecutor);

Content content = client.getListById("2").getContent();

ContactList list = content.getJAXBObject(ContactList.class);

--> now list.id is properly populated but list.name=null

The returned XML looks like this:

<?xml version="1.0" encoding="UTF-8"?>

<entry xmlns="http://www.w3.org/2005/Atom">

<link href="{some link}" rel="edit"></link>

 <id>{some link}</id>

<title type="text">{some text}</title>



<name>{some text}</name>


<content type="application/vnd.ctct+xml">16:44:25.992

 <ContactList xmlns="{some namespace}" id="{some text}">



<ShortName> test</ShortName>




<id>{some text}</id>

<title type="text">{some text}</title>

<link href="lists"></link>

<link href="lists" rel="self"></link>


<name>{some text}</name>






Any help greatly appreciated!


I spoke with David Berard on our AppConnect team who mentioned that you had resolved this issue on your own. If you are still running into any problems please let us know. With that being said, if you did want to post the solution you came up with so that other people can benefit from it as well, that would be much appreciated. Thanks!

David J

Occasional Participant

I was able to solve my issue by using @javax.xml.bind.annotation.XmlSchema(namespace = "http://ws.constantcontact.com/ns/1.0/", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)  in my package-info.java file. 

Developer Portal

View API documentation, code samples, get your API key.

Visit Page