Specifying Web Service Credentials

Applies to TestComplete 14.81, last modified on May 04, 2021

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 Testing Web Services - Overview.

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
Testing Web Services - Overview
Creating Web Service Tests
Testing Web Services

Highlight search results