【问题标题】:Error: Your session expired due to inactivity. ATG REST API session confirmation Number Missmatch错误:您的会话由于不活动而过期。 ATG REST API 会话确认号码不匹配
【发布时间】:2016-06-02 13:31:14
【问题描述】:

我正在使用 REST API 开发 ATG 门户,所有 ATG API 都使用 PostMan 进行了测试。 当我开始在 JS 中工作时出现错误。以下是测试代码:

http({
            method : "GET",
            url : "http://IP:PORT/rest/model/atg/rest/SessionConfirmationActor/getSessionConfirmationNumber"               
         }).then(function mySucces(response){
              // localStorage.setItem("getSessionConfirmationNumer", response.data.sessionConfirmationNumber);
              // localStorage.getItem("getSessionConfirmationNumer");   
            http({
                    method : "GET",
                    url : "http://IP:PORT/rest/model/atg/userprofiling/ProfileActor/login?_dynSessConf="+response.data.sessionConfirmationNumber+"&login=atgcust1&password=atgcust1",
                    // url : "http://IP:PORT/rest/model/atg/userprofiling/ProfileActor/login",
                    // data:formData
                 }).then(function mySucces(response){
                      console.log("done");
                 },function errorCallback(response) {
                    console.log(response);

                });
         });

从控制台输出:

angular.js:10722 GET http://IP:PORT/rest/model/atg/userprofiling/ProfileActor/login?_dynSessConf=9030570900570011195&login=atgcust1&password=atgcust1 409 (冲突)(匿名函数) @ angular.js:10722p @ angular.js:10515g @ angular.js:10222(匿名函数) @ angular.js:14745n.$ eval @ angular.js:15989n.$digest @ angular.js:15800n.$apply @ angular.js:16097(匿名函数) @ angular.js:23554n.event.dispatch @ jQuery-2.1.4.min.js: 3r.handle@jQuery-2.1.4.min.js:3 函数.js:75

Object {data: "Your session expired due to inactivity.", status: 409, config: Object, statusText: "Conflict"}

会话确认号只能访问一次,之后会出现500内部服务器错误(这个逻辑我写的不在这里),

当我从浏览器手动获取会话确认号并在代码中手动将其作为 _dynSessConf 值时,登录正常

请帮忙。

【问题讨论】:

  • 请帮助,任何来自 ATG 和 Angular 背景的专家。

标签: angular-http atg atg-dynamo atg-droplet atg-dust


【解决方案1】:

某些 JSON 库(如 org.json)在解析大长字符串时存在问题。 对于我的代码恰好发生的大多头,它们产生的值略有不同,

SessionConfirmationNumber 通过 JSON 作为 Long 数据类型返回,并且由于 SessionConfirmationNumber 很大,我得到了四舍五入的值。

我已经使用 xmlHttp 请求解决了这个问题。

var xmlHttp = new XMLHttpRequest();
        xmlHttp.open( "GET", "http://IP:PORT/rest/model/atg/rest/SessionConfirmationActor/getSessionConfirmationNumber", false ); 
        xmlHttp.send();
        console.log(xmlHttp.responseText);

感谢上帝:)

【讨论】:

    猜你喜欢
    • 2011-03-02
    • 1970-01-01
    • 1970-01-01
    • 2013-03-13
    • 1970-01-01
    • 1970-01-01
    • 2019-02-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多