In this tutorial we will create a simple IBAN checker using WCF in Visual Studio 2013. The tutorial will demonstrate how easy it is to connect to and consume the Validate web service.
Creating the Basic Project
For simplicity sake we will create a very simple Console Application project.
Open Visual Studio 2013 and create a new project. File > New > Project.
You should choose the 'Console Application' in the Visual c# group.
Next we will add a service reference to the Validate Web Service.
In the Solution Explorer, right click 'Reference' and select 'Add Service Reference;.
In the Address box type or copy the validate web service URL and click the 'Go' button.
We will also change the Namespace to 'ValidateService' in the Namespace text box.
Click 'OK' to create the service reference.
Now we can write some simple WCF code to consume the service and validate a test IBAN: 'GB29NWBK60161331926819'. There are many different ways to consume the Validate service. I am just going to show you a very simple way by just adding code to the main method.
First we will define a few stings to hold the IBAN we want to validate and the keycode. In your code you would obviously use your own Validate Service keycode that has been supplied to you by Paygate.
static void Main(string[] args)
Next we will create an instance of the WCF client that was created when you added the Validate reference: Add the following line to your code:
ValidateService.
validateSoapClient client = new ValidateService.validateSoapClient();
we can now use the client object to access all of the functionality that Validate offers by calling methods in the client object.
To validate an IBAN we would use the method 'validateIban'. This method takes two string parameters in it's signature: Your validate service keycode and the IBAN to validate. This method returns an instance of 'iban ' that contains the validation result, details of the bank and branch and any error messages.
ValidateService.
iban validateResult = client.validateIban(keycode, iban);A property of 'iban' called 'validity' holds the validation result of the IBAN validation process:
Console.WriteLine("The IBAM: {0} is {1}", iban, validateResult.validity);
The full listing is as follows:
static void Main(string[] args)
ValidateService.
validateSoapClient client = new ValidateService.validateSoapClient();
Which gives the result:
![]() |
©Copyright 2023 Paygate Solutions Limited |