simplexml convertor always write java class name as xml root tag

137 Views Asked by At

I'm using Retrofit2 as REST client and SimpleXmlConverterFactory for converting from Java to xml, and from xml to Java object.

When I send response with NotificationResponse through REST, no one of the anotations seem to be applied.

@Root(name = "response")
public class NotificationResponse {
    @Element(name="message")
    private String msg;
    @Element(name="version")
    private String ver;
}

Instead of :

<response>
    <message>Hello</message>
    <version>1</version>
</response>

I'm sending:

<NotificationResponse>
<msg>Hello</msg>
<ver>1</ver>
</NotificationResponse>

Any idea, why @Root and @Element are ignored?

0

There are 0 best solutions below