UserName Property

Applies to TestComplete 15.63, last modified on April 23, 2024
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

Use this property to define the authentication information (user name and password) used by a user to identify himself in the web service under test.

Declaration

WebServiceCredentialsObj.UserName

Read-Only Property CredentialsUserName object
WebServiceCredentialsObj An expression, variable or parameter that specifies a reference to a WebServiceCredentials object

Applies To

The property is applied to the following object:

Property Value

The CredentialsUserName object that assists you in defining the user name and password used for authenticating the client to the service under test.

Remarks

In Microsoft objects, the CredentialsUserName object is implemented via the UserNamePasswordClientCredential class. For information on this class, see its documentation in the MSDN library.

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

WebServiceCredentials Object
About Testing Web Services

Highlight search results