Phone sales support +39 0575 05077
  Phone technical support +39 0575 0508
 

5.2 Read the DNS records

By using the Aruba WsDNS method GetDNSRecords user can retrieve a list DnsREcords in a specified input Dns zone.
Parameters
DNSServiceID
Type: int
id of DNS service.


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

        StringBuilder stringBuilder = new StringBuilder();

        try
        {
            // create the object request
            GetDNSRecordsRequest request = new GetDNSRecordsRequest();
            request.DNSServiceID = DNSServiceID;

            // call method WsResultOfGetDNSRecordsResponse 
            // obtaining a WsResult item
            WsResultOfGetDNSRecordsResponse result = 
                client.GetDNSRecords(request); 

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

                DNSRecord[] items = result.Value.DNSRecords;

                foreach (DNSRecord item in items)
                {
                    stringBuilder.Append("\n -- DNS Record ---\n");
                    stringBuilder.Append("\nName : ");
                    stringBuilder.Append(item.Name);
                       
                    if (item.Priority.HasValue)
                    {
                        stringBuilder.Append("\nPriority : ");
                        stringBuilder.Append(item.Priority.Value);
                    }

                    stringBuilder.Append("\nRecordType : ");
                    stringBuilder.Append(item.RecordType);
                       
                    if (item.TTL.HasValue)
                    {
                        stringBuilder.Append("\nTTL : ");
                        stringBuilder.Append(item.TTL.Value);
                    }

                    stringBuilder.Append("\nContent : ");
                    stringBuilder.Append(item.Content);
                }
            }
            else
            {
                throw new ApplicationException(result.ResultMessage);
            }
        }
        catch (Exception ex)
        {
            // re-run the error
            throw new ApplicationException(ex.Message);
        }

        return stringBuilder.ToString();
    }
    
/// WsDns.GetDNSRecords Method (JAVA)
public static String GetDNSRecords(IWsDNS client,
        int DNSServiceID) 
    {
    //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 {
        // create the object request
        GetDNSRecordsRequest request = new GetDNSRecordsRequest();
        request.setDNSServiceID(DNSServiceID);

        // call method WsResultOfGetDNSRecordsResponse 
        // obtaining a WsResult item
        WsResultOfGetDNSRecordsResponse result = client.getDNSRecords(request);

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

            List dnsRecordList = result.getValue().getDNSRecords().getDNSRecord();

            for (Iterator<DNSRecord> it = dnsRecordList.iterator(); 
                it.hasNext();)
               {
                DNSRecord dnsRecord = it.next();
                stringBuilder.append("\n -----  DNS Record  -------\n");
                stringBuilder.append("\nName : ");
                stringBuilder.append(dnsRecord.getName());


                stringBuilder.append("\nPriority : ");
                stringBuilder.append(dnsRecord.getPriority());


                stringBuilder.append("\nRecordType : ");
                stringBuilder.append(dnsRecord.getRecordType());

                stringBuilder.append("\nTTL : ");
                stringBuilder.append(dnsRecord.getTTL());


                stringBuilder.append("\nContent : ");
                stringBuilder.append(dnsRecord.getContent());
            }
        } else {
            throw new Exception(result.getResultMessage());
        }
    } catch (Exception ex) {
        //show error
        System.out.println(ex);
    }

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




Bookmark and Share