CredentialsUserName Object

Applies to TestComplete 15.47, last modified on January 20, 2023
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 CredentialsUserName object provides a program interface to client credentials (user name and password) for the web service that will be tested with the Web Service project element.

You obtain the CredentialsUserName object in scripts through the UserName property of the WebServiceCredentials object.

The CredentialsUserName object provides a scripting interface to the client credentials. It contains two properties that help you configure the credential object that the client uses to authenticate itself to the service.

Properties

Property Description
UserName Read/Write. Gets or sets the user name used by the client to authenticate itself to the web service under test.
Password Read/Write. Gets or sets the password used by the client to authenticate itself to the web service under test.

Example

The following code defines the client credentials based on user name and password.

JavaScript, JScript

function ServiceCredentials()
{
  var MyWebService, Crd, UserName;
  
  // Obtain the web service under test
  MyWebService = WebServices.SampleWebService;
  
  // Call the web service's Credentials property
  Crd = MyWebService.Credentials;
  
  // Obtain the user name object
  UserName = Crd.UserName;
  
  // Specify the user name and password
  UserName.UserName = "Tester";
  UserName.Password = "123456";
}

Python

def ServiceCredentials():
  # Obtain the web service under test
  MyWebService = WebServices.SampleWebService
  # Call the web service's Credentials property 
  Crd = MyWebService.Credentials
  # Obtain the user name object
  UserName = Crd.UserName
  # Specify the user name and password
  UserName.UserName = "Tester"
  UserName.Password = "123456"

VBScript

Sub ServiceCredentials

  Dim MyWebService, Crd, UserName
  
  ' Obtain the web service under test
  Set MyWebService = WebServices.SampleWebService
  
  ' Call the web service's Credentials property
  Set Crd = MyWebService.Credentials
  
  ' Obtain the user name object
  Set UserName = Crd.UserName
  
  ' Specify the user name and password
  UserName.UserName = "Tester"
  UserName.Password = "123456"

End Sub

DelphiScript

function ServiceCredentials();
var MyWebService, Crd, UserName : OleVariant;
begin

  // Obtain the web service under test
  MyWebService := WebServices.SampleWebService;
  
  // Call the web service's Credentials property
  Crd := MyWebService.Credentials;
  
  // Obtain the user name object
  UserName := Crd.UserName;
  
  // Specify the user name and password
  UserName.UserName := 'Tester';
  UserName.Password := '123456';

end;

C++Script, C#Script

function ServiceCredentials()
{
  var MyWebService, Crd, UserName;
  
  // Obtain the web service under test
  MyWebService = WebServices["SampleWebService"];
  
  // Call the web service's Credentials property
  Crd = MyWebService["Credentials"];
  
  // Obtain the user name object
  UserName = Crd["UserName"];
  
  // Specify the user name and password
  UserName["UserName"] = "Tester";
  UserName["Password"] = "123456";
}

See Also

UserName Property
WebServiceCredentials Object
About Testing Web Services

Highlight search results