请帮忙,我正在android应用程序和服务器之间建立连接,我使用android和nginx的改装作为代理,当我使用postMan时,一切正常,但是当我通过android应用程序尝试时,我收到了消息
{"timestamp":1548830303461,"status":500,"error":"Internal Server Error","exception":"java.lang.NullPointerException","message":"No message available"
这是我的代码:
final String key = Constant.getKey(24);
System.out.println("asd key "+key);
OkHttpClient.Builder httpClient = new OkHttpClient.Builder();
httpClient.addInterceptor(new Interceptor() {
@Override
public okhttp3.Response intercept(Chain chain) throws IOException {
Request original = chain.request();
Request request = original.newBuilder()
.addHeader("authorization_token",key)
//.header("authorization_token",key)
//.header("partner_identifier",Constant.PARTNER_IDENTIFIER)
//.header("partner_auth",Constant.PARTNER_AUTH)
.method(original.method(), original.body())
.build();
return chain.proceed(request);
}
});
OkHttpClient client = httpClient.build();
System.out.println("asd ip "+Constant.URL_SERVICE_SECURE);
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(Constant.URL_SERVICE_SECURE) //http://backendService/login}
.addConverterFactory(ScalarsConverterFactory.create())
.addConverterFactory(GsonConverterFactory.create())
.client(client)
.build();
ApiService apiInterface = retrofit.create(ApiService.class);
paramObject = new JSONObject();
try{
tripleDes = new TripleDes(key);
paramObject.put("msisdn",txtPhoneNumber.getText());
encryptedBody = tripleDes.encrypt(paramObject.toString());
}catch (JSONException e){
System.out.println("asd JSON Exception : "+e.toString());
}catch (Exception e){
System.out.println("asd encrypt error :"+e.toString());
}
System.out.println("asd enc "+encryptedBody);
Call<String> call = apiInterface.check_msisdn(encryptedBody);
call.enqueue(new Callback<String>() {
@Override
public void onResponse(Call<String> call, Response<String> response) {
try{
System.out.println("asd respon 1"+response.errorBody().string());
System.out.println("asd respon 2"+response.message().toString());
System.out.println("asd respon 3"+response.raw().toString());
System.out.println("asd respon 4"+response.code());
}else{
Snackbar.make(getView(),valueUser.rm,Snackbar.LENGTH_SHORT).show();
}
}catch (Exception e){
System.out.println("asd catch "+e.toString());
Snackbar.make(getView(),"Cannot processing server's response !",Snackbar.LENGTH_SHORT).show();
}
progressDialog.dismiss();
}
@Override
public void onFailure(Call<String> call, Throwable t) {
Snackbar.make(getView(),"Oops, Something wrong please try again later or check your internet connection",Snackbar.LENGTH_SHORT).show();
System.out.println("asd failure "+t.toString());
progressDialog.dismiss();
}
});
}
使用Nginx服务器时出现此错误,如果我使用的服务器不使用代理服务器,则可以正常工作
在此先感谢您,谢谢您使用的语言