<?ph=
p
/* Disable cache */
ini_set('soap.wsdl_cache_enabled', 0);
/* Connection data */
$ip =3D 'CHANGEME'; // ip or hostname of the server, without port
$auth->username =3D 'CHANGEME'; //username and password
$auth->password =3D 'CHANGEME';
/*the id of the client who will own the zone */
$client_id =3D 'CHANGEME';=20
/* set SSL context options */
$streamContext =3D stream_context_create(array(
'ssl' =3D> array(
'verify_peer' =3D> false,
'verify_peer_name' =3D> false,
'allow_self_signed' =3D> true
)
));
/* Create SOAP client based on WSDL, with trace for debugging */
$client =3D new SoapClient("https://".$ip."/soap/schema/1.5/dnsmanagerservi=
ce.wsdl", array('trace' =3D> 1, 'exceptions' =3D> 1, 'stream_context'=
=3D> $streamContext));
$authvalues =3D new SoapVar($auth, SOAP_ENC_OBJECT, "http://4psa.com/Header=
Data.xsd/1.0");
$header =3D new SoapHeader('http://4psa.com/HeaderData.xsd/1.0', 'userCrede=
ntials', $authvalues, false);
$client->__setSoapHeaders(array($header));
/* Add dns zone*/
$zone =3D new stdClass();
$zone->name =3D 'myzone.test';
$zone->clientId =3D $client_id;
$zone->type =3D 'master';=20
$result =3D $client ->AddDNSZone($zone);
echo "\n\n=3D=3D=3D=3D=3D=3DAddDNSZone=3D=3D=3D=3D=3D=3D=3D\n";
echo "\n<pre> REQUEST AddDNSZone :\n</pre>";
echo preg_replace(array("/></i", "/</i", "/>/i", "/\n/i"), arra=
y(">\n<", "<", ">", "<br />"), $client-&g=
t;__getLastRequest() );
echo "\n<pre> RESPONSE AddDNSZone :\n</pre>";
echo preg_replace(array("/></i", "/</i", "/>/i", "/\n/i"), arra=
y(">\n<", "<", ">", "<br />"), $client-&g=
t;__getLastResponse() );
/*Add dns record - NS*/
$add_dns_record->DNSZoneName =3D'myzone.test.';
$add_dns_record->status =3D 'enabled';
$add_dns_record->type =3D 'NS';
$add_dns_record->value =3D 'ns1.mynszone.test.';
$result =3D $client->AddDNSRecord($add_dns_record); =20
/*Add dns record - A*/
$add_dns_record->DNSZoneName =3D'myzone.test.';
$add_dns_record->status =3D 'enabled';
$add_dns_record->type =3D 'A';
$add_dns_record->host =3D 'www'; //or FQDN: 'www.myzone.test.'
$add_dns_record->value =3D '1.1.1.1';
$result =3D $client->AddDNSRecord($add_dns_record); =20
/*display SOAP request and response for add "A" dns record */
echo "\n\n=3D=3D=3D=3D=3D=3DAddDNSRecord=3D=3D=3D=3D=3D=3D=3D\n";
echo "\n<pre> REQUEST AddDNSRecord :\n</pre>";
echo preg_replace(array("/></i", "/</i", "/>/i", "/\n/i"), arra=
y(">\n<", "<", ">", "<br />"), $client-&g=
t;__getLastRequest() );
echo "\n<pre> RESPONSE AddDNSRecord :\n</pre>";
echo preg_replace(array("/></i", "/</i", "/>/i", "/\n/i"), arra=
y(">\n<", "<", ">", "<br />"), $client-&g=
t;__getLastResponse() );
/* Parse SOAP response and get DNSRecordId of the record previously added*/
$res =3D $client->__getLastResponse();
$xml =3D new SimpleXMLElement($res);
$dns_record_container =3D $xml->children('SOAP-ENV',true)->Body->c=
hildren("ns3", true)->AddDNSRecordResponse->children("ns2", true)->=
;DNSRecord->children("ns2", true) ;=20
$dns_record =3D $dns_record_container->DNSRecordId;
$dns_record_id =3D $dns_record[0];
/* Edit dns record */
$edit_dns_record =3D new stdClass();
$edit_dns_record->host =3D 'ftp.myzone.test.';
$edit_dns_record->value =3D '2.2.2.2';
$edit_dns_record->DNSRecordId =3D $dns_record_id;
$edit_dns_record->status =3D 'disabled';
$result =3D $client->EditDNSRecord($edit_dns_record);=20
/*display SOAP request and response for edit the "A" record */
echo "\n\n=3D=3D=3D=3D=3D=3DEditDNSRecord=3D=3D=3D=3D=3D=3D=3D\n";
echo "\n<pre> REQUEST EditDNSRecord :\n</pre>";
echo preg_replace(array("/></i", "/</i", "/>/i", "/\n/i"), arra=
y(">\n<", "<", ">", "<br />"), $client-&g=
t;__getLastRequest() );
echo "\n<pre> RESPONSE EditDNSRecord :\n</pre>";
echo preg_replace(array("/></i", "/</i", "/>/i", "/\n/i"), arra=
y(">\n<", "<", ">", "<br />"), $client-&g=
t;__getLastResponse() );
?>