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:
To obtain the WebService
object in tests, use the following syntax:
-
WebServices
is the predefined name of the top-level object that provides access to the collection of tested web services. To access the object, you must have the Web Services collection added to your project. See Adding and Removing Project Items and Their Child Elements. -
WebServiceItem_Name
is the name of the Web Service item that is added to the Web Services collection of your project and stores information on your tested web service. You can view the name in the Project Explorer panel.
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
{
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
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
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
{
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