好吧,我使用的web服务的调用上的应用程序的工作,
Well, I am working on a app using webservices calls,
我打电话给我的登录web服务如下:
I am calling my Login webservice as follows
String url = "http://mydomaim.com/login.php";
UserFunctions userFunction = new UserFunctions();
JSONObject json = userFunction.loginUser(userEmail, password, url);
它工作正常,并给我答复,如下图所示。
it works fine and send me response as show below
{
"userName":"a",
"login_success":1,
"user_id":"3",
"session_id":"1067749aae85b0e6c5c5e697b61cd89d",
"email":"a"
}
我解析这个响应,并成功并获得一个变量的会话ID。 现在,我必须调用其它Web服务附加这些SESSION_ID作为cookie的值。
I parse this response, and successfully and got the session id in a variable. Now i have to call an other webservice appending this session_id as cookie value.
问
如何存放 SESSION_ID
在我的Android设备中的我的cookie值和调用其它Web服务。
How to store the session_id
as the my cookie value in my android device and call other webservice.
下面是我的PHP Web服务code。
here is my php webservice code.
请帮忙。
试试这个,当用户登录调用此请求。
Try this, When login Call this request.
DefaultHttpClient httpClient = new DefaultHttpClient();
String paramString = URLEncodedUtils.format(params, "utf-8");
url += "?" + paramString;
HttpGet httpGet = new HttpGet(url);
HttpResponse httpResponse = httpClient.execute(httpGet);
List<Cookie> cookies = httpClient.getCookieStore().getCookies();
for (Cookie cookie : cookies) {
System.out.println("Cookie: " + cookie.toString());
if (cookie.getName().contains("PHPSESSID"))
guid = cookie.getValue();
}
HttpEntity httpEntity = httpResponse.getEntity();
is = httpEntity.getContent();
上一篇:Cucumber-JVM 3 - io.cucumber.datatable.UndefinedDataTableTypeExceptionio、JVM、Cucumber、UndefinedDataT