I'm connecting webservice by using Okhttp in Android.Firstly I login, and after this, I query another webservice but my session lost. Because of this , webservice return to me "Log in again !" warning. Where is the problem ?
Login.java
public class QueryWord {
public static final MediaType JSON
= MediaType.parse("application/json; charset=UTF-8");
JSONObject run(String url, String level) throws IOException, JSONException {
try {
RequestBody body = new FormEncodingBuilder()
.add("mode", level).build();
Request request;
request = new Request.Builder()
.url(url)
.post(body)
.build();
Response responses = null;
try {
responses = CommonClient.getClient().newCall(request).execute();
} catch (IOException e) {
e.printStackTrace();
}
String jsonData = responses.body().string();
return new JSONObject(jsonData);
}
catch (JSONException error){
Log.e("JSON Error : ", error.getMessage());
return null;
}
}
}
OueryWord.java
public class QueryWord {
public static final MediaType JSON
= MediaType.parse("application/json; charset=UTF-8");
JSONObject run(String url, String level) throws IOException, JSONException {
try {
RequestBody body = new FormEncodingBuilder()
.add("mode", level).build();
Request request;
request = new Request.Builder()
.url(url)
.post(body)
.build();
Response responses = null;
try {
responses = CommonClient.getClient().newCall(request).execute();
} catch (IOException e) {
e.printStackTrace();
}
String jsonData = responses.body().string();
return new JSONObject(jsonData);
}
catch (JSONException error){
Log.e("JSON Error : ", error.getMessage());
return null;
}
}
}