0 Replies Latest reply: May 30, 2012 3:20 PM by 361137 RSS

    How do I achieve this desired structure w/ annotations?

    361137
      I want my resulting xml out of JAX-WS to look like this:

      <S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
      <S:Body>
      <ns2:getTestResponse xmlns:ns2="http://webservice.test/">
      <return>
      <top-layer>
      <children>
      <child id="1"/>
      </children>
      </top-layer>
      </return>
      </ns2:getTestResponse >
      </S:Body>
      </S:Envelope>

      but I cant seem to get that output with the way I annotate my objects.

      I am trying to do it with 2 classes, a class called TopLayer and a Child class which are definted like this:

      @XmlRootElement(name = "top-layer")
      public class TopLayer {

      @XmlElement(name="children")
      List<Child> children;
      }


      public class Child{

      @XmlAttribute(name="id")
      int id;
      }

      of course omitted the getters/setters (Actually my annotations are on the getters but doing it this way for readability)

      But the resulting xml out of the jax-ws response looks odd, it totally omits the top-layer tag, and just puts:

      <return>
      <children id="1000"/>
      </return>

      Do I have to throw in 2 more classes just to get the structure I want?

      Edited by: trant on May 30, 2012 1:20 PM