Hi amine (or Salam?),

Try the following annotations in your object declaration:

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;

@XmlType(name="MyObject")
@XmlAccessorType(XmlAccessType.PROPERTY)
@XmlRootElement(name="MyObject")
public class MyObject {
   //add your getters and setters here...
}

-------------------

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;

@XmlRootElement(name="MyObjectList")
@XmlType(name="MyObjectList")
@XmlAccessorType(XmlAccessType.FIELD)
public class MyObjectList {
   @XmlElement(nillable=true, name="MyObject")
   private List<MyObject> objects = new ArrayList<MyObject>();
   //add your getters and setters here...
}

I'm using default JAXB and I don't see any "duplication" of the nodes. Hth.

Gabo

P.S. I am not sure how this relates to my original question. :)

amine amine wrote:
Salam,

Hi Gabo,

 I want to ask you about combining JAX-WS and JAX-RS, for me it's my
interface that contains annotations (WS & RS) and I'm using @XmlElement,
@XmlRootelement and @XmlWrapper. it works both services WS and RESTfulWS are
available, but the XML structure of the responses give double XML nodes

like this bellow (the Clients node figures two times and the expected is
only once) :
<ClientsList>
<Clients>
  <Clients>
     <Client>
     </Client>
     <Client>
     </Client>
  </Clients>
</Clients>
</ClientsList>

thank you in advance! and good luck !

Reply via email to