AutomationHosts_LoadByCriteria Operation

Applies to QAComplete 12.80 SaaS, last modified on April 20, 2021
This functionality is provided by the automated testing bridge that allows obtaining TestComplete test results to the QAComplete Automation screen.
Starting from the release 9.9.0, this functionality is obsolete and is supported only for backward compatibility.

Returns an array of AutomationHost objects that meet the specified condition. If no condition is specified, the method returns all hosts registered in the specified projects.

The operation can get hosts from one or several projects. To specify a project to get hosts from, use the ProjId value in the AuthenticationData object in the request body. To get hosts from several projects, use the ProjIds value in the AuthenticationData object to specify the list of project IDs.

The method returns hosts in pages (subsets of data) rather than all at once. The number of pages and the number of hosts each page contains is controlled by the PageSize and PageNumber parameters. For information about working with pages, see LoadByCriteria Operations.

Requirements

The user must belong to a security group that has the Read privilege for Automation Hosts.

Parameters

The operation uses the following parameters:

AuthenticationData  :  object, required

An AuthenticationData object with the login information and the ID of the project (or the list of project IDs) whose hosts you want to get.

Condition  :  string, required

A condition (in XML format) the hosts must meet. Wrap the condition into the CDATA tag or encode XML entities.

If you do not specify a condition, the method will return all hosts in your project.

Sorting  :  string, required

Specifies a property by which the method will sort the hosts. If you do not specify any property for sorting, the method will sort the hosts by AutomationHostId.

PageSize  :  integer, required

Specifies how many hosts a single page contains (from 1 to 200).

PageNumber  :  integer, required

Specifies the number of the page from which you want to get hosts.

Result

An array of the AutomationHost objects that meet the criteria.

Example

Sample Code

C#

string login = "john.doe@example.com";
string password = "p@ssword";

ServiceSoapClient service = new ServiceSoapClient();

// Prepare AuthenticationData
LoginInfo loginInfo = service.GetLoginInfo("", login, password);
AuthenticationData authData = new AuthenticationData();
authData.AppCode = loginInfo.AppCode;
authData.UserId = loginInfo.UserId;
authData.PassCode = password;
authData.DeptId = loginInfo.DeptId;
authData.ProjId = loginInfo.ProjId;

// Specify the condition
string condition =
        @"<Conditions xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
        xmlns:xsd='http://www.w3.org/2001/XMLSchema' Operation='opEQU'>
        <Items Type='tField'>
            <Value xsi:type='xsd:string'>CreateUserId</Value>
          </Items>
          <Items Type='tString'>
            <Value xsi:type='xsd:string'>24661</Value>
          </Items>
        </Conditions>";

// Specify the sorting
string sorting = "AutomationHostId";
// Specify the number of items on a page
int pageSize = 200;
// Specify the number of a page
int pageNumber = 1;

// Get the array of hosts
AutomationHost[] hosts = new AutomationHost[0];
do
{
  hosts = service.AutomationHosts_LoadByCriteria(authData, condition, sorting, pageSize, pageNumber);
    foreach (AutomationHost host in hosts)
    {
      // Printing the ID and name of each host
      Console.WriteLine("{0}: {1}", host.AutomationHostId, host.HostName);
    }
  pageNumber++;
}
while (hosts.Length == pageSize);

Java

String login = "john.doe@example.com";
String password = "p@ssword";

ServiceSoap service = new Service().getServiceSoap12();

// Prepare AuthenticationData
LoginInfo loginInfo = service.getLoginInfo("", login, password);
AuthenticationData authData = new AuthenticationData();
authData.setAppCode(loginInfo.getAppCode());
authData.setUserId(loginInfo.getUserId());
authData.setPassCode(password);
authData.setDeptId(loginInfo.getDeptId());
authData.setProjId(loginInfo.getProjId());

// Specify the condition
String condition =
          "<Conditions xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'\n" +
          "  xmlns:xsd='http://www.w3.org/2001/XMLSchema' Operation='opEQU'> \n" +
          "  <Items Type='tField'> \n" +
          "    <Value xsi:type='xsd:string'>CreateUserId</Value> \n" +
          "  </Items> \n" +
          "  <Items Type='tString'> \n" +
          "    <Value xsi:type='xsd:string'>24661</Value> \n" +
          "  </Items> \n" +
          "</Conditions>";

// Specify the sorting
String sorting = "AutomationHostId";
// Specify the number of items on a page
int pageSize = 200;
// Specify the number of a page
int pageNumber = 1;
List<AutomationHost> hosts;
do
{
  hosts = service.automationHostsLoadByCriteria(authData, condition, sorting, pageSize, pageNumber).getAutomationHost();
  for (AutomationHost host : hosts)
  {
    // Printing the ID and name of each host
    System.out.format("%d: %s%n", host.getAutomationHostId(), host.getHostName());
  }
  pageNumber++;
}
while (hosts.size() == pageSize);

Sample Request XML

POST /psws/psws.asmx HTTP/1.1
Host: myteam.mysite.com
Content-Type: text/xml; charset=utf-8
Content-Length: 930 {Insert an appropriate value here}
SOAPAction: "http://www.pragmaticsw.com/AutomationHosts_LoadByCriteria"
 

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <AutomationHosts_LoadByCriteria xmlns="http://www.pragmaticsw.com/">
      <AuthenticationData>
      </AuthenticationData>
      <Condition> &lt;Conditions xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'&#xD;
          xmlns:xsd='http://www.w3.org/2001/XMLSchema' Operation='opEQU'&gt;&#xD;
          &lt;Items Type='tField'&gt; &#xD;
            &lt;Value xsi:type='xsd:string'&gt;CreateUserId&lt;/Value&gt; &#xD;
          &lt;/Items&gt; &#xD;
          &lt;Items Type='tString'&gt; &#xD;
            &lt;Value xsi:type='xsd:string'&gt;24661&lt;/Value&gt; &#xD;
          &lt;/Items&gt; &#xD;
&lt;/Conditions&gt;
</Condition>
      <Sorting>AutomationHostId</Sorting>
      <PageSize>200</PageSize>
      <PageNumber>1</PageNumber>
    </AutomationHosts_LoadByCriteria>
  </soap:Body>
</soap:Envelope>

SOAP 1.2

POST /psws/psws.asmx HTTP/1.1
Host: myteam.mysite.com
Content-Type: application/soap+xml; charset=utf-8
Content-Length: 938 {Insert an appropriate value here}
 

<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
  <soap12:Body>
    <AutomationHosts_LoadByCriteria xmlns="http://www.pragmaticsw.com/">
      <AuthenticationData>
      </AuthenticationData>
      <Condition> &lt;Conditions xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'&#xD;
          xmlns:xsd='http://www.w3.org/2001/XMLSchema' Operation='opEQU'&gt;&#xD;
          &lt;Items Type='tField'&gt; &#xD;
            &lt;Value xsi:type='xsd:string'&gt;CreateUserId&lt;/Value&gt; &#xD;
          &lt;/Items&gt; &#xD;
          &lt;Items Type='tString'&gt; &#xD;
            &lt;Value xsi:type='xsd:string'&gt;24661&lt;/Value&gt; &#xD;
          &lt;/Items&gt; &#xD;
&lt;/Conditions&gt;
</Condition>
      <Sorting>AutomationHostId</Sorting>
      <PageSize>200</PageSize>
      <PageNumber>1</PageNumber>
    </AutomationHosts_LoadByCriteria>
  </soap12:Body>
</soap12:Envelope>

Sample Response XML

HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: 1084 {The server returns an appropriate value here}
 

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <AutomationHosts_LoadByCriteriaResponse xmlns="http://www.pragmaticsw.com/">
      <AutomationHosts_LoadByCriteriaResult>
        <AutomationHost>
          <AutomaticHostId>1</AutomaticHostId>
          <HostName>Test-WinXPx86</HostName>
          <Description>Test host with Windows XP x86</Description>
          <CreateUserId>24661</CreateUserId>
          <UpdateUserId>24661</UpdateUserId>
          <DateCreated>2014-07-20T09:26:39</DateCreated>
          <DateUpdated>2014-08-12T10:17:52</DateUpdated>
        </AutomationHost>
        <AutomationHost>
          <AutomaticHostId>2</AutomaticHostId>
          <HostName>Test-WinVistax64</HostName>
          <Description>Test host with Windows Vista x64</Description>
          <CreateUserId>24661</CreateUserId>
          <UpdateUserId>24661</UpdateUserId>
          <DateCreated>2014-07-21T10:03:13</DateCreated>
          <DateUpdated>2014-07-21T11:29:43</DateUpdated>
        </AutomationHost>
      </AutomationHosts_LoadByCriteriaResult>
    </AutomationHosts_LoadByCriteriaResponse>
  </soap:Body>
</soap:Envelope>

SOAP 1.2

HTTP/1.1 200 OK
Content-Type: application/soap+xml; charset=utf-8
Content-Length: 1094 {The server returns an appropriate value here}
 

<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
  <soap12:Body>
    <AutomationHosts_LoadByCriteriaResponse xmlns="http://www.pragmaticsw.com/">
      <AutomationHosts_LoadByCriteriaResult>
        <AutomationHost>
          <AutomaticHostId>1</AutomaticHostId>
          <HostName>Test-WinXPx86</HostName>
          <Description>Test host with Windows XP x86</Description>
          <CreateUserId>24661</CreateUserId>
          <UpdateUserId>24661</UpdateUserId>
          <DateCreated>2014-07-20T09:26:39</DateCreated>
          <DateUpdated>2014-08-12T10:17:52</DateUpdated>
        </AutomationHost>
        <AutomationHost>
          <AutomaticHostId>2</AutomaticHostId>
          <HostName>Test-WinVistax64</HostName>
          <Description>Test host with Windows Vista x64</Description>
          <CreateUserId>24661</CreateUserId>
          <UpdateUserId>24661</UpdateUserId>
          <DateCreated>2014-07-21T10:03:13</DateCreated>
          <DateUpdated>2014-07-21T11:29:43</DateUpdated>
        </AutomationHost>
      </AutomationHosts_LoadByCriteriaResult>
    </AutomationHosts_LoadByCriteriaResponse>
  </soap12:Body>
</soap12:Envelope>

See Also

Automation Hosts Operations
AutomationHosts_Add
AutomationHosts_Delete
AutomationHosts_Load
AutomationHosts_Update
Automated Testing Bridge Operations
SOAP API Reference

Highlight search results