我正在尝试使用http://ec.europa.eu/taxation_customs/vies/vieshome.do?selectedLanguage=EN 在c#中检查是否正常
[ClassInterface(ClassInterfaceType.AutoDual)]
[ProgId("DotNetCOM.VerificareCIF")]
public class VerificareCIF
{
public string tara = "RO";
public bool valid = false;
public DateTime data;
public String firma = String.Empty;
public String adresa = String.Empty;
public bool VerifCIF(string CIF)
{
eu.europa.ec.checkVatService service = new eu.europa.ec.checkVatService();
data = service.checkVat(ref tara, ref CIF, out valid, out firma, out adresa);
return valid;
}
}
我添加网络参考时崩溃
答案 0 :(得分:1)
如果您不想依赖VIES的网站,您可以使用这些正则表达式,用该国家的前两个字母进行散列:
VAT_NUMBER_FORMATS = {
'IE' => /[0-9a-z]{12}/i,
'DK' => /\d{8}/,
'FI' => /\d{8}/,
'LU' => /\d{8}/,
'MT' => /\d{8}/,
'SI' => /\d{8}/,
'HU' => /\d{8}/,
'CZ' => /\d{8,10}/,
'ES' => /[0-9a-z]{9}/i,
'CY' => /\d{8}[a-z]/i,
'DE' => /\d{9}/,
'EL' => /\d{9}/,
'GR' => /\d{9}/,
'PT' => /\d{9}/,
'EE' => /\d{9}/,
'SK' => /\d{8,10}/,
'LT' => /\d{9,12}/,
'GB' => /\d{9}/,
'AT' => /U\d{8}/,
'PL' => /\d{10}/,
'BE' => /\d{10}/,
'LV' => /[0-9a-z]{11}/i,
'IT' => /\d{11}/,
'FR' => /\d{12}/,
'NL' => /[0-9a-z]{12}/i,
'SE' => /\d{12}/,
}
答案 1 :(得分:0)
psu - 在返回之前检查输出值(输出有效),因为如果服务调用中出现错误,则可能是未定义的。
吉姆