1
try{
        HttpEntity entity=null;
        HttpGet httpget=null;
        HttpResponse  response=null;

        httpclient = new DefaultHttpClient();

        httpget = new HttpGet(credentialsURL);

        httpget.setHeader(HttpHeaders.USER_AGENT, "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/15.0.874.120 Safari/535.2");
            response = httpclient.execute(httpget);

            entity = response.getEntity();

                if (entity != null) {

                    EntityUtils.consume(entity);
                }
        }
        catch(Exception e){

        }
        return httpclient;

我正在使用 HttpClient 处理会话。这是我使用 httpclient 处理会话的代码。但是 httpclient 不会处理 ajax 调用。我打算搬到 httpunit 来解决我的问题。基本上我有一个推荐 URL(或身份验证服务器),我需要从中获取 cookie 和会话并将其存储在客户端中。并在整个网站上使用此客户端来获取登录的用户信息。使用 httpunit 的适当解决方案是什么?credentialsURL="https://www.,,,,.com./sapLogin.aspx?HOOK_URL=https://authentication.server.address&username=&password= ";

4

0 回答 0