gpt4 book ai didi

android - 改造2中的响应{协议(protocol)= http/1.1,代码= 404,消息=未找到,url = https://sub.domain.com}

转载 作者:太空狗 更新时间:2023-10-29 16:25:54 26 4
gpt4 key购买 nike

在iis 7中,我们成功地使用应用程序获取令牌,但是当我们将应用程序服务器从iis7升级到iis 8时,应用程序服务器返回以下错误…
响应{protocol=http/1.1,代码=404,消息=not found,url=https://sub.domain.com}
我们的改装2单吨级如下

public class RetrofitSingleton {

public static final String BASE_URL = "https://sub.domain.com";

private static Retrofit retrofit = null;
private static Context sContext;
private static Retrofit sRetrofit;

public RetrofitSingleton() {
}

public synchronized static Retrofit getInstance(Context context) {
sContext=context;
if(sRetrofit==null){
createRetrofit();
}
return sRetrofit;
}

private static void createRetrofit(){

TrustManagerFactory trustManagerFactory = null;
try {
trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
try {
trustManagerFactory.init((KeyStore) null);
} catch (KeyStoreException e) {
e.printStackTrace();
}
TrustManager[] trustManagers = trustManagerFactory.getTrustManagers();
if (trustManagers.length != 1 || !(trustManagers[0] instanceof X509TrustManager)) {
throw new IllegalStateException("Unexpected default trust managers:" + Arrays.toString(trustManagers));
}
X509TrustManager trustManager = (X509TrustManager) trustManagers[0];
SSLContext sslContext = null;
try {
sslContext = SSLContext.getInstance("SSL");
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
try {
sslContext.init(null, new TrustManager[] { trustManager }, null);
} catch (KeyManagementException e) {
e.printStackTrace();
}
SSLSocketFactory sslSocketFactory = sslContext.getSocketFactory();

OkHttpClient okHttpClient= null;
okHttpClient = new OkHttpClient.Builder()
.sslSocketFactory(new TLSSocketFactory(),trustManager)
.connectTimeout(2, TimeUnit.MINUTES)
.readTimeout(2, TimeUnit.MINUTES)
.writeTimeout(2, TimeUnit.MINUTES)
//.sslSocketFactory(sslSocketFactory, trustManager)
.followRedirects(false)
.followSslRedirects(false)
.retryOnConnectionFailure(false)
.cache(null)//new Cache(sContext.getCacheDir(),10*1024*1024)
.build();

sRetrofit= new Retrofit.Builder()
.client(okHttpClient)
.baseUrl(BASE_URL)
.addConverterFactory(GsonConverterFactory.create())
.build();
}

在我们的改装2 API接口之后
@FormUrlEncoded
@POST("/Api/Token")
Call<TokenInfo> getTokenAccess(@Field("grant_type") String grantType);

我们无法理解,由于将IIS 7升级到IIS 8,需要更改make anywhere的配置/代码。任何建议都非常感谢。
提前谢谢。
注:
 1. Using Postman we get token from our Asp.net Web api but from our android 
app we cannot get token using retrofit 2.

2. In IIS 7, our application & app works successfully.

最佳答案

你的改装单品课看起来不错。这可能不是您的IIS问题。对于ssl,iis 8比iis 7提供了更多的灵活性。在我的例子中,我遇到了iis 8的ssl配置不完整的问题。尝试使用正确的IIS SSL配置。遵循给定的链接:
https://www.sslsupportdesk.com/ssl-installation-instructions-for-windows-iis-8-and-8-5/

关于android - 改造2中的响应{协议(protocol)= http/1.1,代码= 404,消息=未找到,url = https://sub.domain.com},我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54086673/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com