WebService Object

Applies to TestComplete 14.92, last modified on September 16, 2021

Description

The WebService object provides a scripting interface to a tested web service added to the Web Services collection of your TestComplete project:

The Web Services collection and its items

To obtain the WebService object in tests, use the following syntax:

WebServices.WebServiceItem_Name

The WebService object contains methods whose names and parameters coincide with the names and parameters of methods of the tested web service. In addition, the WebService object contains several properties that help you create complex objects needed for methods’ calls and help you analyze the contents of the last request sent to and the last response received from the service. For more information, see Testing Web Services.

Members

Example

The following example shows how to get the tested web service in script and how to call its methods.

JavaScript, JScript

function WebServiceDemo()
{

  var MyWebService, Str;

  // Obtains the tested web service
  MyWebService = WebServices.SampleWebService;
  // Calls a web service method that returns a string
  Str = MyWebService.HelloWorld;
  // Posts the string returned by the web service method to the log
  Log.Message(Str);

}

Python

def WebServiceDemo():
  # Obtains the tested web service 
  MyWebService = WebServices.SampleWebService
  # Calls a web service method that returns a string 
  Str = MyWebService.HelloWorld
  # Posts the string returned by the web service method to the log 
  Log.Message(Str)

VBScript

Sub WebServiceDemo

  Dim MyWebService, Str

  ' Obtains the tested web service
  Set MyWebService = WebServices.SampleWebService
  ' Calls a web service method that returns a string
  Str = MyWebService.HelloWorld
  ' Posts the string returned by the web service method to the log
  Log.Message(Str)

End Sub

DelphiScript

procedure WebServiceDemo();
var
  MyWebService, Str;

begin

  // Obtains the tested web service
  MyWebService := WebServices.SampleWebService;
  // Calls a web service method that returns a string
  Str := MyWebService.HelloWorld;
  // Posts the string returned by the web service method to the log
  Log.Message(Str);

end;

C++Script, C#Script

function WebServiceDemo()
{

  var MyWebService, Str;

  // Obtains the tested web service
  MyWebService = WebServices["SampleWebService"];
  // Calls a web service method that returns a string
  Str = MyWebService["HelloWorld"];
  // Posts the string returned by the web service method to the log
  Log["Message"](Str);

}

See Also

WebServices Object
Testing Web Services
Testing Web Services - Overview
About Web Service Checkpoints

Highlight search results