Domains and DNS > 3 - Advanced Domains Management > Change the domain nameservers

3.5 Change the domain nameservers

By using the Aruba WsDomains method SetDomainNameServers is possible to change authoritative nameservers of a domain with those in input.

Parameters
domainFullName
Type: String
Full name of the domain.

dnsEntyties
Type: DnsHostEntity
Array of DnsHostEntity object with hostname and ip address of each dns entry.


    /// WsDomains.SetDomainNameServers Method (c# .NET)
    public static string SetDomainNameServers(WsDomainsClient client,
        String domainFullName, DnsHostEntity[] dnsEntities)
    {
        //specify the account login details 
        client.ClientCredentials.UserName.UserName = "ARU-0000";
        client.ClientCredentials.UserName.Password = "0123456789";

        StringBuilder stringBuilder = new StringBuilder();

        try
        {
            SetDomainNameServersRequest request = 
                new SetDomainNameServersRequest();

            request.Body = new DomainDnsHostsEntity();
            request.Body.DnsHosts = dnsEntities;
            request.Body.DomainName = new InputDomainNameEntity();
            request.Body.DomainName.DomainFullName = domainFullName;
               

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

            //if the call is Success print history values
            if (result.Success)
            {
                // get Value returned from server
                stringBuilder.Append("Operation ends successfully. Result Code:");
                stringBuilder.Append(result.ResultCode);
            }
            else
            {
                throw new ApplicationException(result.ResultMessage);
            }
        }
        catch (Exception ex)
        {
            // re-run the error
            throw new ApplicationException(ex.Message);
        }

        return stringBuilder.ToString();
    }
    
/// WsDomains.SetDomainNameServers Method (JAVA)
public static String SetDomainNameServers(IWsDomains client,
        String domainFullName, ArrayOfDnsHostEntity dnsEntities) 
    {
    //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 {
        SetDomainNameServersRequest request = new SetDomainNameServersRequest();
        request.setBody(new DomainDnsHostsEntity());
        request.getBody().setDnsHosts(dnsEntities);
        request.getBody().setDomainName(new InputDomainNameEntity());
        request.getBody().getDomainName().setDomainFullName(domainFullName);


        // call method SetDomainNameServers 
        // obtaining a WsResult item
        WsResult result = client.setDomainNameServers(request);

        //if the call is Success print history values
        if (result.isSuccess()) {
            // get Value returned from server
            stringBuilder.append("Operation ends successfully. Result Code : ");
            stringBuilder.append(result.getResultCode());
        } 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/wsDomains/v2.8/WsDomains.svc?wsdl
See also