LastRequest Property

Applies to TestComplete 15.47, last modified on January 20, 2023
Testing web services with TestComplete is obsolete. We recommend that you use ReadyAPI, another SmartBear's automated testing tool for SOAP and REST web services.
If needed, you can run ReadyAPI tests from TestComplete.

Description

Use this property to obtain access to the contents of the last SOAP request that was sent to the tested web service that corresponds to the WebServiceObj object. The property returns an object implementing the IXMLDOMDocument interface (SOAP uses XML and the request contents match the DOM model). You can use methods and properties of this object to parse the request contents.

Declaration

WebServiceObj.LastRequest

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 request sent to the tested web service, parses and modifies it, then it uses the modified request to create a new request to be sent to the web service.

JavaScript, JScript

function WebServiceRequestDemo()
{

  var WebServiceInfo, method, LastRequest, Request, NewObject, NewRequest;

  // Obtains the WebServiceInfo object
  WebServiceInfo = WebServices.CreateWebServiceInfoFromItem("SampleWebService");
  // Specifies the method to which the request will be sent
  method = "SetSampleObject";

  

  // Obtains the last SOAP request sent to the tested web service
  LastRequest = WebServices.SampleWebService.LastRequest;

  // Parses the request content
  Request = WebServiceInfo.ParseRequest(method, LastRequest);
  // Obtains the object containing input parameters for the method
  NewObject = Request.obj;

  // Modifies the values to be used to call the method
  NewObject.Name = "Modified sample object";
  NewObject.X = 0.4;
  NewObject.Y = 0.6;

  // Generates a new SOAP request to be sent to the specified method
  NewRequest = WebServiceInfo.PrepareRequest(method, Request);

  …

}

Python

def WebServiceRequestDemo():
  # Obtains the WebServiceInfo object 
  WebServiceInfo = WebServices.CreateWebServiceInfoFromItem("SampleWebService")
  # Specifies the method to which the request will be sent 
  method = "SetSampleObject"
  # ...
  # Obtains the last SOAP request sent to the tested web service 
  LastRequest = WebServices.SampleWebService.LastRequest
  # Parses the request content 
  Request = WebServiceInfo.ParseRequest(method, LastRequest)
  # Obtains the object containing input parameters for the method 
  NewObject = Request.obj
  # Modifies the values to be used to call the method 
  NewObject.Name = "Modified sample object"
  NewObject.X = 0.4
  NewObject.Y = 0.6
  # Generates a new SOAP request to be sent to the specified method 
  NewRequest = WebServiceInfo.PrepareRequest(method, Request)
  # ...

VBScript

Sub WebServiceRequestDemo

  Dim WebServiceInfo, method, LastRequest, Request, NewObject, NewRequest

  ' Obtains the WebServiceInfo object
  Set WebServiceInfo = WebServices.CreateWebServiceInfoFromItem("SampleWebService")
  ' Specifies the method to which the request will be sent
  method = "SetSampleObject"

  

  ' Obtains the last SOAP request sent to the tested web service
  Set LastRequest = WebServices.SampleWebService.LastRequest

  ' Parses the request content
  Set Request = WebServiceInfo.ParseRequest(method, LastRequest)
  ' Obtains the object containing input parameters for the method
  Set NewObject = Request.obj

  ' Modifies the values to be used to call the method
  NewObject.Name = "Modified sample object"
  NewObject.X = 0.4
  NewObject.Y = 0.6

  ' Generates a new SOAP request to be sent to the specified method
  Set NewRequest = WebServiceInfo.PrepareRequest(method, Request)

  …

End Sub

DelphiScript

procedure WebServiceRequestDemo();
var
  WebServiceInfo, method, LastRequest, Request, NewObject, NewRequest;

begin

  // Obtains the WebServiceInfo object
  WebServiceInfo := WebServices.CreateWebServiceInfoFromItem('SampleWebService');
  // Specifies the method to which the request will be sent
  method := 'SetSampleObject';

  

  // Obtains the last SOAP request sent to the tested web service
  LastRequest := WebServices.SampleWebService.LastRequest;

  // Parses the request content
  Request := WebServiceInfo.ParseRequest(method, LastRequest);
  // Obtains the object containing input parameters for the method
  NewObject := Request.obj;

  // Modifies the values to be used to call the method
  NewObject.Name := 'Modified sample object';
  NewObject.X := 0.4;
  NewObject.Y := 0.6;

  // Generates a new SOAP request to be sent to the specified method
  NewRequest := WebServiceInfo.PrepareRequest(method, Request);

  …

end;

C++Script, C#Script

function WebServiceRequestDemo()
{

  var WebServiceInfo, method, LastRequest, Request, NewObject, NewRequest;

  // Obtains the WebServiceInfo object
  WebServiceInfo = WebServices["CreateWebServiceInfoFromItem"]("SampleWebService");
  // Specifies the method to which the request will be sent
  method = "SetSampleObject";

  

  // Obtains the last SOAP request sent to the tested web service
  LastRequest = WebServices["SampleWebService"]["LastRequest"];

  // Parses the request content
  Request = WebServiceInfo["ParseRequest"](method, LastRequest);
  // Obtains the object containing input parameters for the method
  NewObject = Request["obj"];

  // Modifies the values to be used to call the method
  NewObject["Name"] = "Modified sample object";
  NewObject["X"] = 0.4;
  NewObject["Y"] = 0.6;

  // Generates a new SOAP request to be sent to the specified method
  NewRequest = WebServiceInfo["PrepareRequest"](method, Request);

  …

}

See Also

LastResponse Property
About Testing Web Services

Highlight search results