我正在尝试制作XML响应,但有一个例外。
onFailure中的例外情况: org.simpleframework.xml.core.ElementException:元素'Date'在类中没有匹配
客户端
public static Retrofit getXMLClient() {
if (retrofitXML == null) {
retrofitXML = new Retrofit.Builder()
.baseUrl(BASE_URL)
.client(okHttpClient)
.addConverterFactory(SimpleXmlConverterFactory.create())
.build();
}
return retrofitXML;
}
接口
@GET("odds-" + oddsAccessMode + "1"+"?")
Call<PojoOddsResponse> getOddsData(@Query("api_key") String api_key);
API调用
ApiInterfaceSR apiService =
ApiClientSR.getXMLClient().create(ApiInterfaceSR.class);
Call<PojoOddsResponse> call = apiService.getOddsData(API_KEY);
call.enqueue(new Callback<PojoOddsResponse>() {
@Override
public void onResponse(Call<PojoOddsResponse> call, Response<PojoOddsResponse> response) {
if (response.body() != null && response.code() == 200) {
try {
String s = response.body().toString();
Log.d(TAG, "onResponse: "+s);
} catch (Exception e) {
Log.e("JSON exception", e.getMessage());
}
}
}
@Override
public void onFailure(Call<PojoOddsResponse> call, Throwable t) {
Log.e("api exception", t.getMessage());
}
});
请帮帮我。