Skip to content

ericmuijs/VIESCheckVatService

 
 

Repository files navigation

VIES Check Vat: C# Client Example

1. Overview

You can verify the validity of a VAT number issued by any Member State by the European Information Exchange System (VIES) system for validation of VAT numbers. For more information on this service please visit VIES VAT number validation

The VIES has publicly exposed this service through the SOAP protocol. The service is called checkVatService and the WSDL document is located at the following address WSDL checkVatService.

This C# project implements a simple SOAP client to use the VIES services.

2. Project details

The project is divided into two sub-projects:

  • VIESCheckVatService : Contains the SOAP proxy class and some interfaces and classes of boundary.
  • VIESCheckVatServiceClient : It contains a simple Windows application that uses the service via the VIES SOAP client.

Figure 1 shows the classes and interfaces created to interact with the service. In detail:

  • IVIESCheckVatService : Generically defines the interface for interaction with the services VIES.
  • VIESCheckVatServicesSOAPImpl : Class that implements the interface defined above. This class is specific to interact via SOAP.
  • VIESCheckServiceFactory : Factory class that returns the correct implementation of the client that interacts with the services VIES. The implementation is supported SOAP.
  • VIESVatModel : This class represents the set of data returned by the service VIES.

Figure 1. Class Diagram of the VIESCheckVatService

Please find below an example of C # code that shows the use of the VIES service.

VIESCheckVatService.IVIESCheckVatService iCheckVatService =
    VIESCheckVatService.VIESCheckServiceFactory.getService(ServiceType.SOAP);

VIESCheckVatService.VIESVatModel vatModel = iCheckVatService.getDetailVAT("IT", "01983251678");

Console.Out.WriteLine("Valid: " + vatModel.Valid);
Console.Out.WriteLine("County Code: " + vatModel.CountryCode);
Console.Out.WriteLine("VAT Number: " + vatModel.VatNumber);
Console.Out.WriteLine("Request Date: " + vatModel.RequestDate);
Console.Out.WriteLine("Org. Name: " + vatModel.Name);
Console.Out.WriteLine("Org. Address: " + vatModel.Address);

Source Code 1. Example C# client code that use VIES service

The following figures show the windows application (available in the project) that interacts with the VIES service.

Figure 2. Validation VAT number OK

Figure 3. Validation VAT number FAILED

Figure 4. Validation VAT number field required

Figure 5. Validation VAT number FAILED for network problems

Figure 6. Validation VAT number FAILED for SOAP Fault

The project was developed using the SharpDevelop tool (version 4.4). In addition, the project has been tested and run on the platform. NET 4.

3. Notes

To use the service you are invited to read the document Specific disclaimer for this service issued by the European Commission.

4. Resources

About

VIES VAT Number validation

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 100.0%