WebService Object

Applies to TestComplete 15.45, last modified on December 01, 2022
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

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 About 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
About Testing Web Services
About Testing Web Services
About Web Service Checkpoints

Highlight search results