Announcement Announcement Module
No announcement yet.
Rest client with receive list of XML using annotations Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Rest client with receive list of XML using annotations

    Hi everyone,
    I'm trying to receive atoms from a repository
    the form of the xml i want to retrieve is the following:

    <authors xmlns="http://www.../ckp" xmlns:atom="">
    <atom:link rel="author" type="application/xml" href="http://www.../ckp/author/1"/>
    <atom:link rel="author" type="application/xml" href="http://www.../ckp/author/2"/>

    I declare a package-info:

    @javax.xml.bind.annotation.XmlSchema (
    xmlns = {
    @javax.xml.bind.annotation.XmlNs( prefix=" ", namespaceURI="http://www.../ckp"),
    @javax.xml.bind.annotation.XmlNs( prefix="atom" ,namespaceURI="")
    package org.client.model;

    import javax.xml.bind.annotation.*;

    I declare a class Author:

    import javax.xml.bind.annotation.*;

    public class Author {

    private String author;
    private String name;
    private String address;
    private String affiliation;
    private String email;

    public String getAuthor() {
    return author;

    public void setAuthor(String author) { = author;

    public String getName() {
    return name;

    public void setName(String name) { = name;

    public String getAddress() {
    return address;

    public void setAddress(String address) {
    this.address = address;

    public String getAffiliation() {
    return affiliation;

    public void setAffiliation(String affiliation) {
    this.affiliation = affiliation;

    public String getEmail() {
    return email;

    public void setEmail(String email) { = email;

    The aformentioned class says that each one of the authors has name,address,affiliation,email
    Individual authors i can retrieve from the www.../ckp/author/1

    But my problem is that i can not retrieve the list. The code i try is the following:
    public class Atomlink {

    private String rel;
    private String type;
    @XmlAttribute(required = true)
    private String href;

    public String getRel() {
    return rel;

    public void setRel(String rel) {
    this.rel = rel;
    public String getType() {
    return type;

    public void setType(String type) {
    this.type = type;
    public String getHref() {
    return href;

    public void setHref(String href) {
    this.href = href;

    This is the class for the atom and after i create a class called AuthorMeta:
    public class AuthorMeta {

    private Atomlink link;

    public Atomlink getLink() {
    return link;

    public void setLink(Atomlink link) { = link;

    And finally the class authors:
    public class Authors {

    private String authors;

    public void setAuthors(String authors) {
    this.authors = authors;

    public String getAuthors() {
    return authors;

    private List<AuthorMeta> data;

    public List<AuthorMeta> getData() {
    return data;

    public void setData(List<AuthorMeta> data) { = data;
    And the view is the following:

    <%@ taglib uri="" prefix="c" %>
    <%@ page language="java" contentType="text/html; charset=UTF-8"
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Insert title here</title>

    <c:url var="addUrl" value="/add" />
    <table style="border: 1px solid; width: 500px; text-align:center">
    <thead style="background:#fcf">
    <th colspan="4"></th>
    <c:forEach items="${authors}" var="author">
    <c:url var="editUrl" value="/update?id=${}" />
    <c:url var="deleteUrl" value="/delete?id=${}" />
    <c:url var="getUrl" value="/author?id=${}" />
    <td><c:out value="${}" /></td>
    <td><c:out value="${author.address}" /></td>
    <td><c:out value="${author.affiliation}" /></td>
    <td><c:out value="${}" /></td>
    <td><a href="${editUrl}">Edit</a></td>
    <td><a href="${deleteUrl}">Delete</a></td>
    <td><a href="${addUrl}">Add</a></td>
    <td><a href="${getUrl}">Get</a></td>

    <c:if test="${empty authors}">
    There are currently no persons in the list. <a href="${addUrl}">Add</a> a person.


    Can anyone tells me what i'm doing wrong?

  • #2
    Please help me. I'm trying to retrieve the atom list one week now