Android Web服务会话管理
我正在开发一个使用Web服务的android应用程序。首先,应用程序通过下面写的httppost方法登录Android Web服务会话管理,android,service,web,Android,Service,Web,我正在开发一个使用Web服务的android应用程序。首先,应用程序通过下面写的httppost方法登录 public void postData() throws ParseException, IOException { httpclient = new DefaultHttpClient(); HttpPost httppost = new HttpPost("http://192.168.0.46:8080/login"); httppost.addHeader
public void postData() throws ParseException, IOException
{
httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://192.168.0.46:8080/login");
httppost.addHeader("Content-Type", "application/x-www-form-urlencoded");;
HttpResponse responses = null;
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
nameValuePairs.add(new BasicNameValuePair("LoginForm[email]", "t@a.com"));
nameValuePairs.add(new BasicNameValuePair("LoginForm[password]", "tttttt"));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
responses = httpclient.execute(httppost);
HttpEntity responseEntity = responses.getEntity();
String apitoken = EntityUtils.toString(responseEntity);
}
现在,apitoken是keyseesion键,它将返回服务和有关该用户的其他数据
public void getCategories {
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://192.168.0.46:8080/usercategories");
httppost.addHeader("Content-Type", "application/x-www-form-urlencoded");;
HttpResponse responses = null;
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(1);
nameValuePairs.add(new BasicNameValuePair("api_token", apitoken));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
try {
responses = httpclient.execute(httppost);
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
} catch (IOException e) {
// TODO Auto-generated catch block
}
HttpEntity responseEntity = responses.getEntity();
String category =EntityUtils.toString(responseEntity) ;
}
}
现在的问题是,服务器会话密钥api_令牌没有被重新签名。。
我在服务器上检查过,这与应用程序从服务器上获得的密钥完全相同。
我在iPhone中实现了相同的Web服务。好的。。
我是android新手,我不明白问题出在哪里。我还应该在客户端或其他地方维护会话吗。
欢迎任何帮助