Forum Discussion

ferranferri's avatar
ferranferri
Occasional Contributor
14 years ago

Parse request doesn't work correcly in my test function

Hello, 



I'm checking some webservices in my application. The webservices plugin retrieves perfectly the methods and attributes published. The problem is when after retrieve the session token (so the communcation is OK), the contents are not correctly parsed (I thinks). This is what I do:




function setDixioPreferences()

{

  // gets the session token in another webservice request

  var sessionToken;



  if(sessionToken == ""){

    sessionToken = SetAuth();

  }

  websrvInfo = WebServices.CreateWebServiceInfoFromItem("contentOrder");  

  ReqObj = websrvInfo.PrepareRequestObject("getContents");

  

  ReqObj.sessionToken = sessionToken;

  ReqObj.language = "es";

  

 websrvInfo.PrepareRequest("getContents", ReqObj);    





  response = WebServices.contentOrder.getContents(ReqObj.sessionToken,   ReqObj.language);

  ll = WebServices.contentOrder.LastResponse;

  

  res = websrvInfo.ParseResponse("getContents", ll);





}



Where getContents is the webservice method that I want to test. The problem is that res is aparently empty. I need to extract an array from res. Checking into a web proxy debugger, I know that communication and contents are correctly sent.

1 Reply

  • Hi Ferran,




    The sessionToken variable is undefined in your script. After the var sessionToken; line is executed, this variable gets the null value. The if(sessionToken == ""){ condition is always false and, therefore, the sessionToken = SetAuth(); line is never executed.




    If this is not the case of the problem, please post here the value of the ll variable:




      ll = WebServices.contentOrder.LastResponse; 


      Log.Message("Find response XML in Additional Information", ll);





    BTW, you do not declare variables in your script (with the var keyword). This makes these variables to be global variables and can cause unpredictable problems. Consider declaring variables before using them.