[英]How can I get request url from retrofit with rx ? - Android
MinSdkVersion
我申请的是17
和targetSdkVersion
是25
。在这个应用我连接,其中Rx和改造维修,这段代码不上工作api 17
我无法连接到webService
,波纹管是我的代码:
我的RetrofitApi.java
:
public class RetrofitApi {
private static PublicApi retrofit = null;
public static PublicApi getClient(String url) {
retrofit = new Retrofit.Builder()
.baseUrl(url)
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
.addConverterFactory(GsonConverterFactory.create())
.build().create(PublicApi.class);
return retrofit;
}
}
我的PublicApi.java
:
public interface PublicApi {
@GET("/web_service/mobile/rest")
Observable<LastNews> lastNews(@Query("function") String function);
}
和:
PublicApi publicApi = RetrofitApi.getClient("https://xxx.xxx.xxx/");
CompositeDisposable mCompositeDisposable = new CompositeDisposable();
mCompositeDisposable.add(publicApi.lastNews("getLastNews")
.observeOn(AndroidSchedulers.mainThread())
.subscribeOn(Schedulers.io())
.subscribe(this::responseLastNews, this::errorLastNews));
private void responseLastNews(LastNews lastNewses){
}
private void errorLastNews(Throwable error) {
Log.i("LOG", error.getMessage());
}
当我在API 17
上进行测试时,收到错误消息并无法连接到服务器。告诉我:
java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
您的基本URL (**https**://xxx.xxx.xxx/)
已通过SSL
,您需要实现SSL
连接才能使其正常工作。
请参考此链接
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.