Domains and DNS > 4 - DNS Management > Read purchased services

4.1 Read purchased services

By using the Aruba WsDNS method GetPurchasedDNS is possible to retrieve the list of Dns services acquired by authenticated user.


    /// WsDns.GetPurchasedDNS Method (c# .NET)
    public static string GetPurchasedDNS(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 GetPurchasedDNS 
            // obtaining a WsResultOfGetPurchasedDNSResponse item
            WsResultOfGetPurchasedDNSResponse result = client.GetPurchasedDNS();

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

                foreach (DNS item in items)
                {
                    stringBuilder.Append("\nDomainName: ");
                    stringBuilder.Append(item.DomainName);
                    stringBuilder.Append("\nDNSServiceID: ");
                    stringBuilder.Append(item.DNSServiceID);
                    stringBuilder.Append("\nDNSProviderExternalID: ");
                    stringBuilder.Append(item.DNSProviderExternalID);

                    stringBuilder.Append("\n---- Hosts -----\n");
                       
                    foreach (Host host in item.Hosts)
                    {
                        stringBuilder.Append("\nHostName: ");                       
                        stringBuilder.Append(host.HostName);
                        stringBuilder.Append("\nIP: ");                       
                        stringBuilder.Append(host.IP);
                    }
                }
            }
            else
            {
                throw new ApplicationException(result.ResultMessage);
            }
        }
        catch (Exception ex)
        {
            // re-run the error
            throw new ApplicationException(ex.Message);
        }

        return stringBuilder.ToString();
    }
    
/// WsDns.GetPurchasedDNS Method (JAVA)
public static String GetPurchasedDNS(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 GetPurchasedDNS 
        // obtaining a WsResultOfGetPurchasedDNSResponse item
        WsResultOfGetPurchasedDNSResponse result = client.getPurchasedDNS();

        //if the call is Success print history values
        if (result.isSuccess()) {
            // get Value returned from server
            stringBuilder.append("Operation ends successfully\n");
            GetPurchasedDNSResponse items = result.getValue(); 
            ArrayOfDNS arrayOfDNS = items.getDNSList();
            List dnsList = arrayOfDNS.getDNS();
            for (Iterator<DNS> it = dnsList.iterator(); it.hasNext();)
                {
                DNS dns = it.next();
                stringBuilder.append("\nDomainName: ");
                stringBuilder.append(dns.getDomainName());
                stringBuilder.append("\nDNSServiceID: ");
                stringBuilder.append(dns.getDNSServiceID());
                stringBuilder.append("\nDNSProviderExternalID: ");
                stringBuilder.append(dns.getDNSProviderExternalID());

                stringBuilder.append("\n---- Hosts -----\n");

                ArrayOfHost arrayOfHost =  dns.getHosts();
                List hostList = arrayOfHost.getHost();
                for (Iterator<Host> it2 = hostList.iterator(); it2.hasNext();)
                {
                    Host host = it2.next();
                    stringBuilder.append("\nHostName: ");
                    stringBuilder.append(host.getHostName());
                    stringBuilder.append("\nIP: ");
                    stringBuilder.append(host.getIP());
                }
            }
        } 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