XML : Jersey Pojo Annotation

I want to create an XML Web Service using Jersey 2.

I have 2 classes represented here by A and B :

  public class A {      private B b;  }    public class B {      @XmlAttribute      private String bString;  }    

and a service class :

  @GET()  @Path("/test")  @Produces(MediaType.APPLICATION_XML)  public ObjetA test(){        A a = new A();      B b = new B();      a.setB(B);                return a;  }    

Is there an annotation or another way to get the following XML output :

  <a bString=""/>    

right now I have this one :

  <a>  <b bstring=""/>  </a>    

As you can see, I want to show bString which is a B field as an attribute of <a>.

Thx.

No comments:

Post a Comment