我怎样才能从 rx 改造中获得请求 url ? - Android

How can I get request url from retrofit with rx ? - Android

我的应用程序的

MinSdkVersion17 并且 targetSdkVersion25 。在这个应用程序中我连接到服务与 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 上测试时出现错误并且不连接到 server.Told 我 :

java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.

您的基地 URL (**https**://xxx.xxx.xxx/) 受到 SSL 的保护,您需要实施 SSL 连接才能使其正常工作。

请参考this link