LastResponse Property

Applies to TestComplete 14.40, last modified on April 22, 2021

Description

Use this property to obtain access to the contents of the last SOAP response that was received from the tested web service that corresponds to the WebServiceObj object. The property returns an object implementing the IXMLDOMDocument interface (SOAP uses XML and the response contents match the DOM model). You can use methods and properties of this object to parse the request contents. For instance, you can use the object to explore the structure of response data. Also, you can use this object to obtain values of the method’s out parameters in JavaScript, JScript, Python, C#Script and C++Script code (these languages do not support out parameters, so you cannot check the parameter values for VBScript or DelphiScript code).

Declaration

WebServiceObj.LastResponse

Read-Only Property IXMLDOMDocument object
WebServiceObj An expression, variable or parameter that specifies a reference to a WebService object

Applies To

The property is applied to the following object:

Property Value

An object implementing the IXMLDOMDocument interface.

Remarks

For information on methods and properties of the IXMLDOMDocument interface and about DOM, see the XML Core Services and Document Object Model article in the MSDN library.

Example

The following code obtains the last web service response, parses it and obtains the object that holds the data returned by the specified web service method. Then it posts the returned data to the log.

JavaScript, JScript

function WebServiceResponseDemo()
{

  var WebServiceInfo, method, Str, LastResponse, Response;

  // Obtains the WebServiceInfo object
  WebServiceInfo = WebServices.CreateWebServiceInfoFromItem("SampleWebService");
  // Specifies the method whose response will be obtained
  method = "SetSampleObject";

  

  // Obtains the last web service response
  LastResponse = WebServices.SampleWebService.LastResponse;

  // Parses the response content
  Response = WebServiceInfo.ParseResponse(method, LastResponse);
  // Posts the data returned by the web service method
  Log.Message(Response.SetSampleObjectResult);

  …

}

Python

def WebServiceResponseDemo():
  # Obtains the WebServiceInfo object 
  WebServiceInfo = WebServices.CreateWebServiceInfoFromItem("SampleWebService")
  # Specifies the method whose response will be obtained 
  method = "SetSampleObject"
  # ... 
  # Obtains the last web service response 
  LastResponse = WebServices.SampleWebService.LastResponse
  # Parses the response content 
  Response = WebServiceInfo.ParseResponse(method, LastResponse)
  # Posts the data returned by the web service method 
  Log.Message(Response.SetSampleObjectResult)
  # ...

VBScript

Sub WebServiceResponseDemo

  Dim WebServiceInfo, method, Str, LastResponse, Response

  ' Obtains the WebServiceInfo object
  Set WebServiceInfo = WebServices.CreateWebServiceInfoFromItem("SampleWebService")
  ' Specifies the method whose response will be obtained
  method = "SetSampleObject"

  

  ' Obtains the last web service response
  Set LastResponse = WebServices.SampleWebService.LastResponse

  ' Parses the response content
  Set Response = WebServiceInfo.ParseResponse(method, LastResponse)
  ' Posts the data returned by the web service method
  Log.Message(Response.SetSampleObjectResult)

  …

End Sub

DelphiScript

procedure WebServiceResponseDemo();
var
  WebServiceInfo, method, Str, LastResponse, Response;

begin

  // Obtains the WebServiceInfo object
  WebServiceInfo := WebServices.CreateWebServiceInfoFromItem('SampleWebService');
  // Specifies the method whose response will be obtained
  method := 'SetSampleObject';

  

  // Obtains the last web service response
  LastResponse := WebServices.SampleWebService.LastResponse;

  // Parses the response content
  Response := WebServiceInfo.ParseResponse(method, LastResponse);
  // Posts the data returned by the web service method
  Log.Message(Response.SetSampleObjectResult);

  …

end;

C++Script, C#Script

function WebServiceResponseDemo()
{

  var WebServiceInfo, method, Str, LastResponse, Response;

  // Obtains the WebServiceInfo object
  WebServiceInfo = WebServices["CreateWebServiceInfoFromItem"]("SampleWebService");
  // Specifies the method whose response will be obtained
  method = "SetSampleObject";

  

  // Obtains the last web service response
  LastResponse = WebServices["SampleWebService"]["LastResponse"];

  // Parses the response content
  Response = WebServiceInfo["ParseResponse"](method, LastResponse);
  // Posts the data returned by the web service method
  Log["Message"](Response["SetSampleObjectResult"]);

  …

}

See Also

LastResponse Property
Testing Web Services

Highlight search results