mwillbanks / MwCommon

Various components to extend and enhance ZF2.
17 stars 5 forks source link

How to validate or skip only when server is busy #5

Open olekhy opened 10 years ago

olekhy commented 10 years ago

Hi Author!

How we need to handle until soap server is buzzy? Hit from traced exception:

SoapFault Object ( 
    [message:protected] => SERVER_BUSY 
    [string:Exception:private] => 
    [code:protected] => 0 
    [file:protected] => /.../vendor/zendframework/zendframework/library/Zend/Soap/Client.php 
    [line:protected] => 1118 
    [trace:Exception:private] => Array ( 
        [0] => Array ( 
            [file] => /.../vendor/zendframework/zendframework/library/Zend/Soap/Client.php 
            [line] => 1118 
            [function] => __soapCall 
            [class] => SoapClient 
            [type] => -> 
            [args] => Array ( 
                    [0] => checkVat 
                    [1] => Array ( 
                        [0] => Array ( 
                            [countryCode] => DE 
                            [vatNumber] => 815246684 
)
olekhy commented 10 years ago

may be add more error messages to validator? I found here: http://forums.oscommerce.de/topic/73224-fehler-abfrage-vat-intracom-number/page-3

try {
    $result = $client->checkVat($params);
} catch (SoapFault $e) { 
    $result = $e->faultstring;
    $regex = '/\{ \'([A-Z_]*)\' \}/';
    $n = preg_match($regex, $result, $matches);
    $result = $matches[1];
    $faults = array(
        'INVALID_INPUT'       => 'The provided CountryCode is invalid or the VAT number is empty',
    'SERVICE_UNAVAILABLE' => 'The SOAP service is unavailable, try again later',
        'MS_UNAVAILABLE'      => 'The Member State service is unavailable, try again later or with another Member State',
        'TIMEOUT'             => 'The Member State service could not be reached in time, try again later or with another Member State',
        'SERVER_BUSY'         => 'The service cannot process your request. Try again later.'
    );        

   $this->error($faults[$result]);
   return false;         
}
olekhy commented 10 years ago

hu hu... :baby:

mwillbanks commented 10 years ago

@olekhy Sorry my apologies.... For some reason github did not email me the notification. I'll attempt to look at tonight.

olekhy commented 10 years ago

thx