Ech, przecież to kilka linijek kodu:
<?php
ini_set('default_socket_timeout',60
); /* 60 sec */ if ( !empty($_REQUEST['countryCode']) ){ $_REQUEST['countryCode'] = mb_strtoupper($_REQUEST['countryCode']);
}
$wsdl = 'http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl';
'countryCode' => $_REQUEST['countryCode'],
'vatNumber' => $_REQUEST['vatNumber']
);
$client = new SoapClient
($wsdl, array( 'trace' => FALSE,
'exceptions' => TRUE,
//'encoding'=>'UTF-8', /* UTF-8 is default option */
'compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP,
));
try {
$result = $client->checkVat($checkVat);
if ( true === (bool)$result->valid){
echo '<h1 style="color:green;">VAT IS VALID</h1>'; }else{
echo '<h1 style="color:red;">VAT IS INVALID</h1>'; }
} catch (SoapFault $exception) {
echo '<h1 style="color:red;">'.$exception->getCode().' - '.$exception->getMessage().'</h1>'; echo '<h1 style="color:red;">'.$exception->faultstring.'</h1>'; }
?>