Here is a simple example of how to consume a WebService in a console app with C#. For this tutorial, we will use the free service from the European commission you can use to validate tax (VAT) number.

Here is the web interface: http://ec.europa.eu/taxation_customs/vies/

First of all, create a new console application (named CheckVat) and add a new service reference.

To do that, you just need to right click on the References and select Add Service Reference:

Visual Studio - add a New Service Reference

Visual Studio – add a New Service Reference

In this window, please enter the address of the service: http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl

And give it a name (Namespace): TaxService

Visual Studio - define new service reference

Visual Studio – define new service reference

Now you can easily call the webservice and use the method checkVat from our TaxService:

Finally, here is the result of our console application, checking the VAT number for a restaurant company:

check VAT result

check VAT result

Respect the rules!

However, be careful. Your IP address can be banned or blacklisted from their services. Don’t spam them with wrong data or too many times with the same VAT number.

http://ec.europa.eu/taxation_customs/vies/help.html

Happy coding!  🙂