问题描述
build.gradle
implementation 'com.tickaroo.tikxml:annotation:0.8.13'
implementation 'com.tickaroo.tikxml:core:0.8.13'
implementation 'com.tickaroo.tikxml:retrofit-converter:0.8.13'
文档.class
@Xml(name = "docs")
public class docs {
@Attribute(name = "docs")
public ArrayList<doc> doc = new ArrayList <>();
}
文档类
public class doc {
@PropertyElement(name="bookname")
String bookname;
@PropertyElement(name="authors")
String authors;
@PropertyElement(name="isbn13")
String isbn13;
@PropertyElement(name="bookImageURL")
String bookImageURL;
public doc(){
}
public doc(String title,String authors,String isbn13,String bookImageURL) {
this.bookname = title;
this.authors = authors;
this.isbn13 = isbn13;
this.bookImageURL = bookImageURL;
}
public String getTitle() {
return bookname;
}
public void setTitle(String title) {
this.bookname = title;
}
public String getAuthors() {
return authors;
}
public void setAuthors(String authors) {
this.authors = authors;
}
public String getIsbn13() {
return isbn13;
}
public void setIsbn13(String isbn13) {
this.isbn13 = isbn13;
}
public String getBookImageURL() {
return bookImageURL;
}
public void setBookImageURL(String bookImageURL) {
this.bookImageURL = bookImageURL;
}
}
main.class
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("http://data4library.kr/api/")
.addConverterFactory(tikxmlConverterFactory.create(tikxml))
.build();
Library retable = retrofit.create(Library.class);
Call <docs> call = retable.getRes("key","2021-04-11");
Log.d("request",call.request().toString());
call.enqueue(new Callback <docs>() {
@Override
public void onResponse(Call <docs> call,Response <docs> response) {
Log.d("Title",livo.get(0).getTitle());
}
@Override
public void onFailure(Call <docs> call,Throwable t) {
Log.d("Test",t.getMessage());
}
});
public interface Library {
@GET("loanItemSrch")
Call<docs> getRes(
@Query("authKey") String authKey,@Query("startDt") String startDt
);
}
使用改造的 XML 解析
类没有 TypeAdapKter
用call.request()接收日志时,地址正常
我已连接,但 onFailure() 方法不断向我显示错误消息
我需要你的帮助。谢谢。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)