2016-06-02 11 views
0

Ich arbeite am ATG Portal mit REST API, alle ATG APIs werden mit PostMan getestet. Es gibt einen Fehler, als ich anfing, in JS zu arbeiten. unten ist der Testcode:Fehler: Ihre Sitzung ist aufgrund von Inaktivität abgelaufen. ATG REST API Sitzungsbestätigung Nummer Missmatch

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); 

       }); 
     }); 

Ausgabe von Console:

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

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

Session Bestätigungsnummer nur einmal zugänglich sein Können nach, dass es 500 Interner Serverfehler geben wird (diese Logik ich geschrieben habe hier nicht enthalten),

Login funktioniert, wenn ich Sitzungsbestätigungsnummer manuell vom Browser erhalten und manuell, dass als _dynSessConf Wert gibt im Code

Bitte helfen Sie.

+0

Bitte helfen Sie, alle Experten von ATG und Angular Hintergrund. –

Antwort

0

Einige JSON-Bibliotheken wie org.json haben ein Problem beim Parsing großer Longs. Sie ergeben einen etwas anderen Wert für große Longs, die genau zu meinem Code passiert,

SessionConfirmationNumber Rückgabe über JSON als Datentyp von Long und ich bekam gerundeten Wert, da die SessionConfirmationNumber groß war.

Ich habe xmlHttp Anfrage zur Lösung dieses Problems verwendet.

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

Gott sei Dank :)

Verwandte Themen