Specifying Web Service Credentials

Applies to TestComplete 15.44, last modified on November 10, 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.

TestComplete provides you with special support for testing of web services. Also, you can create functional tests for WCF services. For more information on web services supported by TestComplete, see About Testing Web Services.

Typically, you do not have to perform any additional actions before starting to work with the service. However, some web services require that the user be authenticated to the service before starting to work with it. To work with such web services, users typically use one of the following authentication approaches:

  • Windows authentication.

  • Basic authentication.

  • Certificate authentication.

  • NTLM authentication.

To test such web services with TestComplete, it is required that the user be authenticated to the service before working with it. For this purpose, TestComplete offers you special program objects that assist you in specifying desired authentication information for the user. To access these objects, use the Credentials property of the WebService object.

The following code defines the Windows credentials for the SampleWebService web service.

JavaScript, JScript

function Test()
{
  var service = WebServices.SampleWebService;

  var auth = service.Credentials.Windows;
  auth.AllowNtlm = true;
  auth.ClientCredentials.UserName = "Tester";
  auth.ClientCredentials.Domain = "QA";
  auth.ClientCredentials.Password = "123456";
}

Python

def Test():
  service = WebServices.SampleWebService;
  auth = service.Credentials.Windows;
  auth.AllowNtlm = True;
  auth.ClientCredentials.UserName = "Tester";
  auth.ClientCredentials.Domain = "QA";
  auth.ClientCredentials.Password = "123456";

VBScript

Sub Test
  Dim service, auth

  Set service = WebServices.SampleWebService

  Set auth = service.Credentials.Windows
  auth.AllowNtlm = True
  auth.ClientCredentials.UserName = "Tester"
  auth.ClientCredentials.Domain = "QA"
  auth.ClientCredentials.Password = "123456"
End Sub

DelphiScript

procedure Test;
var service, auth;
begin
  service := WebServices.SampleWebService;

  auth := service.Credentials.Windows;
  auth.AllowNtlm := true;
  auth.ClientCredentials.UserName := 'Tester';
  auth.ClientCredentials.Domain := 'QA';
  auth.ClientCredentials.Password := '123456';
end;

C++Script, C#Script

function Test()
{
  var service = WebServices["SampleWebService"];

  var auth = service["Credentials"]["Windows"];
  auth["AllowNtlm"] = true;
  auth["ClientCredentials"]["UserName"] = "Tester";
  auth["ClientCredentials"]["Domain"] = "QA";
  auth["ClientCredentials"]["Password"] = "123456";
}

See Also

WebServiceCredentials Object
About Testing Web Services
Creating Web Service Tests
About Testing Web Services

Highlight search results