chris_reynolds
13 years agoOccasional Contributor
Was having trouble interpreting a response from a webservice in JScript
I am using TestComplete 8.70.727.7 to do functional testing on a SOAP web service for the first time.
when I call a webservice such as:
var wsResult = WebServices.CommCalcService.CalculateLapseCancel14DayFreeLook(219027, 2, "20/01/2012 3:06:01 p.m.", "chris", "testcomplete");
Then I get back a response object whose properties exactly match the XML. Excellent so far.
However, they seem to have a typename of ArrayOfBlah and I don't know how to handle that in JScript?
Such as XML result like:
<root>
<logs>
<logLine>aaaaaa</logLine>
<logLine>bbbbb</logLine>
<logLine>cccccc</logLine>
<logs>
</root>
After some help file frustration and then trial and error, I found the simple answer:
var myLogLines = wsResult.logs.logLine.toArray()
The answer was on actually in the help topic "Calling Web Service Methods That Use Out Parameters" but it was a case of being able to find the answer only after you already knew the answer.
I would recommend that this snippet of information appears in several other help topics to make it easier to find.
In particular, it would be useful on help topics "Working With SOAP Requests' and Responses' Data From
Scripts" and "WebServiceInfo.ParseResponse"
when I call a webservice such as:
var wsResult = WebServices.CommCalcService.CalculateLapseCancel14DayFreeLook(219027, 2, "20/01/2012 3:06:01 p.m.", "chris", "testcomplete");
Then I get back a response object whose properties exactly match the XML. Excellent so far.
However, they seem to have a typename of ArrayOfBlah and I don't know how to handle that in JScript?
Such as XML result like:
<root>
<logs>
<logLine>aaaaaa</logLine>
<logLine>bbbbb</logLine>
<logLine>cccccc</logLine>
<logs>
</root>
After some help file frustration and then trial and error, I found the simple answer:
var myLogLines = wsResult.logs.logLine.toArray()
The answer was on actually in the help topic "Calling Web Service Methods That Use Out Parameters" but it was a case of being able to find the answer only after you already knew the answer.
I would recommend that this snippet of information appears in several other help topics to make it easier to find.
In particular, it would be useful on help topics "Working With SOAP Requests' and Responses' Data From
Scripts" and "WebServiceInfo.ParseResponse"