首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >与Lotus Connections的交互

与Lotus Connections的交互
EN

Stack Overflow用户
提问于 2010-10-08 19:01:03
回答 2查看 659关注 0票数 0

我需要从一些lotus连接站点获取数据,例如,从其他站点获取用户状态。我尝试通过java建立与lotus的连接,例如

代码语言:javascript
复制
> server = "https://" + path + param + "&format=full";
> URL profiles_url = new URL(server);
> // Open the URL: throws exception if not found
> HttpURLConnection profiles_conn = HttpURLConnection)profiles_url.openConnection();
> profiles_conn.connect();
> // Process the Atom feed in the response content
> readResponse(profiles_url.openStream(),args[0]);

但我总是得到这样的响应:HTTP/1.1401未经授权请给我任何建议?

EN

回答 2

Stack Overflow用户

发布于 2011-05-04 22:55:49

我用这种方式解决了身份验证问题:

代码语言:javascript
复制
protected void doView(RenderRequest rRequest, RenderResponse rResponse) throws PortletException, IOException, UnavailableException {
try { 
rResponse.setContentType("text/html");          
        URL url = new URL(
                "https://xxx/activities/service/atom2/todos");
        URLConnection con = url.openConnection();
        con.setConnectTimeout(150000);
        con.setReadTimeout(150000);
        writeCookies(con, rRequest);                        

        DO_SOMETHING (con.getInputStream());
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}       


private String doesLTPATokenCookieExists(RenderRequest request) {
Cookie[] cookie = request.getCookies();
for (int i = 0; i < cookie.length; i++) {
    System.out.println("Cookie Name " + cookie[i].getName());
    if (cookie[i].getName().equals("LtpaToken"))
        return cookie[i].getValue();
}
return null;
}

public URLConnection writeCookies(URLConnection urlConn,
    RenderRequest request) {
String cookieString = "";
cookieString += "LtpaToken" + "=" + doesLTPATokenCookieExists(request) + "; ";
urlConn.setRequestProperty("Cookie", cookieString);     
return urlConn;
}
票数 1
EN

Stack Overflow用户

发布于 2011-01-29 02:01:21

您没有提到如何进行身份验证,这一点至关重要。正如401错误所暗示的那样,Connections没有将您的请求视为已通过身份验证。您需要一个有效的Authenticator实例,但是您的代码片段表明您还没有这样做,对吗?

(顺便说一句,在使用Lotus Connections API时,建议使用Apache Abdera项目)。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/3889844

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档