Domains and DNS > 4 - DNS Management > Read the list of purchasable TLD

4.2 Read the list of purchasable TLD

By using the Aruba WsDNS method GetDnsTLDs is possible to retrieve a list of available TLD


    /// WsDns.GetDnsTLDs Method (c# .NET)
    public static string GetDnsTLDs(WsDNSClient client)
    {
        //specify the account login details 
        client.ClientCredentials.UserName.UserName = "ARU-0000";
        client.ClientCredentials.UserName.Password = "0123456789";

        StringBuilder stringBuilder = new StringBuilder();

        try
        {
            // call method GetAllDns 
            // obtaining a WsResult item
            WsResultOfGetDnsTLDsResponse result = client.GetDnsTLDs();

            //if the call is Success print history values
            if (result.Success)
            {
                // get Value returned from server
                stringBuilder.Append("Operation ends successfully\n");

                TopLevelDomain[] items = result.Value.TLDs;
                stringBuilder.Append("\n --- Top Level Domains ---\n");

                foreach (TopLevelDomain item in items)
                {
                    stringBuilder.Append("\nTldID: "); 
                    stringBuilder.Append(item.TldID);
                    stringBuilder.Append("\nTldCode: ");
                    stringBuilder.Append(item.TldCode);
                    stringBuilder.Append("\nDescription: ");
                    stringBuilder.Append(item.Description);
                }
                   
            }
            else
            {
                throw new ApplicationException(result.ResultMessage);
            }
        }
        catch (Exception ex)
        {
            // re-run the error
            throw new ApplicationException(ex.Message);
        }

        return stringBuilder.ToString();
    }
    
/// WsDns.GetDnsTLDs Method (JAVA)
public static String GetDnsTLDs(IWsDNS client) {
    //specify the account login details 
    ((BindingProvider) client).getRequestContext()
            .put(BindingProvider.USERNAME_PROPERTY, "ARU-0000");
    ((BindingProvider) client).getRequestContext()
            .put(BindingProvider.PASSWORD_PROPERTY, "0123456789");

    StringBuilder stringBuilder = new StringBuilder();

    try {
        // call method GetAllDns 
        // obtaining a WsResult item
        WsResultOfGetDnsTLDsResponse result = client.getDnsTLDs();

        //if the call is Success print history values
        if (result.isSuccess()) {
            // get Value returned from server
            stringBuilder.append("Operation ends successfully\n");

            GetDnsTLDsResponse items = result.getValue();
            ArrayOfTopLevelDomain arrayOfTopLevelDomain = items.getTLDs();
            List topLevelDomainList = arrayOfTopLevelDomain.getTopLevelDomain();

            stringBuilder.append("\n ------- Top Level Domains -------\n");

            for (Iterator<TopLevelDomain> it = topLevelDomainList.iterator();
               it.hasNext();)
                {
                TopLevelDomain topLevelDomain = it.next();
                stringBuilder.append("\nTldID: ");
                stringBuilder.append(topLevelDomain.getTldID());
                stringBuilder.append("\nTldCode: ");
                stringBuilder.append(topLevelDomain.getTldCode());
                stringBuilder.append("\nDescription: ");
                stringBuilder.append(topLevelDomain.getDescription());
                }

        } else {
            throw new Exception(result.getResultMessage());
        }
    } catch (Exception ex) {
        //show error
        System.out.println(ex);
    }

    return stringBuilder.toString();
}
Version
API: v2.8 URL:https://api.services.cloud.it/wsDns/v2.8/WsDns.svc?wsdl
See also