Ask a Question

Reading array of objects in web api

SOLVED
NisHera
Valued Contributor

Reading array of objects in web api

I'm having a response of web_api with array of objects.

It seems "ParseResponse" couldn't read end objects any help would appreciate.

 

Below is my inspection on parsed response variable...

 

Capture.PNG

There should be 2 contact_phone details objects include in response (as per SoapUI test)

 

method parameters are as below

Capture1.PNG

Capture2.PNGCapture3.PNG

1 ACCEPTED SOLUTION

Accepted Solutions
AlexKaras
Community Hero

Re: Reading array of objects in web api

Hi,

 

Check sample project from the <Users>\Public\Documents\TestComplete 12 Samples\Common\Web Service Testing\Functional Testing\ folder. It contains example of processing array returned as a result.

Does it help?

Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================

View solution in original post

3 REPLIES 3
AlexKaras
Community Hero

Re: Reading array of objects in web api

Hi,

 

Check sample project from the <Users>\Public\Documents\TestComplete 12 Samples\Common\Web Service Testing\Functional Testing\ folder. It contains example of processing array returned as a result.

Does it help?

Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================

View solution in original post

NisHera
Valued Contributor

Re: Reading array of objects in web api

thanks @AlexKaras 

it is not straight forward.  But could decipher after an hour and half.

If anybody comes across same problem  below is the code 

 

function test123(){
  
  var wsCall, CnPhDetArray ;
  
  WebServices.XXXwsSoap.getContactPhone(28);
  wsCall = WebServices.CreateWebServiceInfoFromItem('XXXwsSoap');
  var CnPhDetArray = wsCall.ParseResponse("getContactPhone",WebServices.XXXwsSoap.LastResponse);

  for(var i = 0; i <= VarArrayHighBound(CnPhDetArray.list.Contact_PhoneDetail, 1); i++)
    Log.Message("Array[" + aqConvert.IntToStr(i) + "] = " + CnPhDetArray.list.Contact_PhoneDetail(i).Phone_Number );
}

 

AlexKaras
Community Hero

Re: Reading array of objects in web api

Hi,

 

Hm... I expected it to be more user-friendly... I did not provide code sample as I did not have TestComplete with Web Services project at hand at that moment, but I would try something like this:

-- As your service has more than one output parameter, call it as per https://support.smartbear.com/testcomplete/docs/app-testing/web/services/out-parameters-methods.html recommendations;

-- Assuming that returned data are in the Contact_PhoneDetail parameter (which is an array), I would expect this code:

  Contact_PhoneDetail[i].Phone_Number;

(Though the above should be verified in debugger|code evaluation window)

Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================
cancel
Showing results for 
Search instead for 
Did you mean: