simplexml convertor always write java class name as xml root tag
up vote
1
down vote
favorite
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?
java retrofit2 simple-xml-converter
add a comment |
up vote
1
down vote
favorite
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?
java retrofit2 simple-xml-converter
Are you sure that you've use right converter to serialize object?
– Ivan Zelenskyy
Nov 19 at 15:05
I'm using: <dependency> <groupId>com.squareup.retrofit2</groupId> <artifactId>converter-simplexml</artifactId> <version>2.3.0</version> </dependency>
– Marijana Teofilovic
Nov 19 at 15:10
I mean, how you initialize you converter? I suppose, you have somewhere a code line with "Retrofit.Builder()..."
– Ivan Zelenskyy
Nov 19 at 15:28
return new Retrofit.Builder() .baseUrl(baseUrl) .client(httpClient()) .addConverterFactory(SimpleXmlConverterFactory.create()) .build();
– Marijana Teofilovic
Nov 19 at 15:36
Strange. Then, I have no answers, but if SimpleXML is not strict dependency for your project, you can use Gson or JAXB, because SimpleXmlConverterFactory is deprecated in retrofit2 starting from version 2.4.0
– Ivan Zelenskyy
Nov 19 at 15:56
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
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?
java retrofit2 simple-xml-converter
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?
java retrofit2 simple-xml-converter
java retrofit2 simple-xml-converter
asked Nov 19 at 14:56
Marijana Teofilovic
61
61
Are you sure that you've use right converter to serialize object?
– Ivan Zelenskyy
Nov 19 at 15:05
I'm using: <dependency> <groupId>com.squareup.retrofit2</groupId> <artifactId>converter-simplexml</artifactId> <version>2.3.0</version> </dependency>
– Marijana Teofilovic
Nov 19 at 15:10
I mean, how you initialize you converter? I suppose, you have somewhere a code line with "Retrofit.Builder()..."
– Ivan Zelenskyy
Nov 19 at 15:28
return new Retrofit.Builder() .baseUrl(baseUrl) .client(httpClient()) .addConverterFactory(SimpleXmlConverterFactory.create()) .build();
– Marijana Teofilovic
Nov 19 at 15:36
Strange. Then, I have no answers, but if SimpleXML is not strict dependency for your project, you can use Gson or JAXB, because SimpleXmlConverterFactory is deprecated in retrofit2 starting from version 2.4.0
– Ivan Zelenskyy
Nov 19 at 15:56
add a comment |
Are you sure that you've use right converter to serialize object?
– Ivan Zelenskyy
Nov 19 at 15:05
I'm using: <dependency> <groupId>com.squareup.retrofit2</groupId> <artifactId>converter-simplexml</artifactId> <version>2.3.0</version> </dependency>
– Marijana Teofilovic
Nov 19 at 15:10
I mean, how you initialize you converter? I suppose, you have somewhere a code line with "Retrofit.Builder()..."
– Ivan Zelenskyy
Nov 19 at 15:28
return new Retrofit.Builder() .baseUrl(baseUrl) .client(httpClient()) .addConverterFactory(SimpleXmlConverterFactory.create()) .build();
– Marijana Teofilovic
Nov 19 at 15:36
Strange. Then, I have no answers, but if SimpleXML is not strict dependency for your project, you can use Gson or JAXB, because SimpleXmlConverterFactory is deprecated in retrofit2 starting from version 2.4.0
– Ivan Zelenskyy
Nov 19 at 15:56
Are you sure that you've use right converter to serialize object?
– Ivan Zelenskyy
Nov 19 at 15:05
Are you sure that you've use right converter to serialize object?
– Ivan Zelenskyy
Nov 19 at 15:05
I'm using: <dependency> <groupId>com.squareup.retrofit2</groupId> <artifactId>converter-simplexml</artifactId> <version>2.3.0</version> </dependency>
– Marijana Teofilovic
Nov 19 at 15:10
I'm using: <dependency> <groupId>com.squareup.retrofit2</groupId> <artifactId>converter-simplexml</artifactId> <version>2.3.0</version> </dependency>
– Marijana Teofilovic
Nov 19 at 15:10
I mean, how you initialize you converter? I suppose, you have somewhere a code line with "Retrofit.Builder()..."
– Ivan Zelenskyy
Nov 19 at 15:28
I mean, how you initialize you converter? I suppose, you have somewhere a code line with "Retrofit.Builder()..."
– Ivan Zelenskyy
Nov 19 at 15:28
return new Retrofit.Builder() .baseUrl(baseUrl) .client(httpClient()) .addConverterFactory(SimpleXmlConverterFactory.create()) .build();
– Marijana Teofilovic
Nov 19 at 15:36
return new Retrofit.Builder() .baseUrl(baseUrl) .client(httpClient()) .addConverterFactory(SimpleXmlConverterFactory.create()) .build();
– Marijana Teofilovic
Nov 19 at 15:36
Strange. Then, I have no answers, but if SimpleXML is not strict dependency for your project, you can use Gson or JAXB, because SimpleXmlConverterFactory is deprecated in retrofit2 starting from version 2.4.0
– Ivan Zelenskyy
Nov 19 at 15:56
Strange. Then, I have no answers, but if SimpleXML is not strict dependency for your project, you can use Gson or JAXB, because SimpleXmlConverterFactory is deprecated in retrofit2 starting from version 2.4.0
– Ivan Zelenskyy
Nov 19 at 15:56
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53377262%2fsimplexml-convertor-always-write-java-class-name-as-xml-root-tag%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Are you sure that you've use right converter to serialize object?
– Ivan Zelenskyy
Nov 19 at 15:05
I'm using: <dependency> <groupId>com.squareup.retrofit2</groupId> <artifactId>converter-simplexml</artifactId> <version>2.3.0</version> </dependency>
– Marijana Teofilovic
Nov 19 at 15:10
I mean, how you initialize you converter? I suppose, you have somewhere a code line with "Retrofit.Builder()..."
– Ivan Zelenskyy
Nov 19 at 15:28
return new Retrofit.Builder() .baseUrl(baseUrl) .client(httpClient()) .addConverterFactory(SimpleXmlConverterFactory.create()) .build();
– Marijana Teofilovic
Nov 19 at 15:36
Strange. Then, I have no answers, but if SimpleXML is not strict dependency for your project, you can use Gson or JAXB, because SimpleXmlConverterFactory is deprecated in retrofit2 starting from version 2.4.0
– Ivan Zelenskyy
Nov 19 at 15:56