http://stackoverflow.com/questions/27436266/how-to-post-json-but-get-xml-response-using-retrofit
mRestAdapter = new RestAdapter.Builder()
.setEndpoint(getBaseUrl())
.setConverter(new SimpleXMLConverter())
.build();
result
public class MixedConverter implements Converter {
private Converter mSerializer;
private Converter mDeserializer;
public MixedConverter(Converter serializer, Converter deserializer) {
mSerializer = serializer;
mDeserializer = deserializer;
}
@Override
public Object fromBody(TypedInput body, Type type) throws ConversionException {
return mDeserializer.fromBody(body, type);
}
@Override
public TypedOutput toBody(Object object) {
return mSerializer.toBody(object);
}
}
and
.setConverter(new MixedConverter(new SimpleXMLConverter(), new GsonConverter(gson)));
网友评论