validateNiNumber

 

Validates an individuals UK National Insurance Number is correct.

 

Syntax:

validateNiNumber (string keycode, string ninumber)

 


 

Returned data


An object niNumber containing the following fields:

 

 Property Type  Explanation 
 valid  Boolean  True if the NI Number is Valid, otherwise False
 validity  String  String ‘Valid’ if the account number is valid.

 String ‘Invalid’ if the account number is not valid. 

number  String  The original NI number is passed back in this property
 errorCode  String  Error code of any returning error.
 errorText  String  Textual description of any returning errors.

 

 


Supported Versions

Validate Web Service Version 1.x


Errors

1700        NI Number length invalid - should be 9 characters.
1701        NI Number invalid.
1702        NI Number invalid. Final character must be A,B,C,D or space.
1703         NI Number invalid. Invalid first character.
1704         NI Number invalid. Invalid second character.
1705         NI Number invalid. First two characters are illegal.


Example Code

c#
The following sample show how to use the validateNiNumber function using c#.
As with all examples, please see the section Adding a reference to the Validate Web Service .

c# Example 1

  validate.validate wsObject = new validate.validate();
  validate.
niNumber niObject = wsObject.validateNiNumber("qwerty", "NW123456D");

 

c# Example 2

using System;
using System.Collections.Generic;
using System.Text;
namespace validateNiNumber
{
  class Program
  {
    static void Main(string[] args)
    {
      string keycode = "qwerty";
      string natInsNumber = "NW123456D";
      validate.
validate wsObject = new validate.validate();
      validate.
niNumber niObject = wsObject.validateNiNumber(keycode, natInsNumber);
      Console.WriteLine(niObject.validity);
      Console.WriteLine(niObject.errorCode);
      Console.WriteLine(niObject.errorText);
      Console.ReadLine();
    }
  }
}

 

Visual Basic .net
The following sample show how to use the validateNiNumber function using Visual Basic.net.
As wilth all examples, please see the section Adding a reference to the Validate Web Service.

 Visual Basic.net Example 1

    Dim wsobject As New validate.validate()  
    Dim niObject As
validate.niNumber
    niObject = wsobject.validateNiNumber("qwerty", "NW123456D")

 

Module Module1
  Sub Main()

    ' define the keycode and iban to use to derive the bic, both as strings.
    Dim keycode As String = "qwerty"
    Dim ni As String = "NW123456D"

    ' Create a web service object
    Dim wsobject As New validate.validate()

    ' create aN object for the returning data
    Dim niObject As validate.niNumber

    ' Call the web service function - validateNiNumber()
    niObject = wsobject.validateNiNumber(keycode, ni)

    ' display the derived bic or the error message
    Console.WriteLine("The NI Number " & ni & " is " & niObject.validity)
    Console.WriteLine(niObject.errorCode)
    Console.WriteLine(niObject.errorText)
    Console.ReadLine()

  End Sub
End
Module

 

Java
The following sample show how to use the validateNiNumber using Java.

Java Example 1

package ninumber;
public class Main {
    pu blic static void main(String[] args) {
   
        validate.Validate service = new validate.Validate();
        validate.ValidateSoap port = service.getValidateSoap12();
        java.lang.String keyCode = "qwerty" ;
        java.lang.String ni = "NW123456D" ;
        validate.niNumber result = port.validateNiNumber(keyCode, ni);
        System.out.println( "NI Number is " +result.validity());
        System.out.println( "Error Code = " +result.getErrorCode());
        System.out.println( "Error Message = " +result.getErrorText());  
       
    }
}

 


XML Messages

Below is a typical XML message request

<?xml version="1.0" encoding="utf-8"?>
<
soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://vtest.bemac.com/">
  <soap:Body>
    <tns:validateNiNumber>
      <tns:keyCode>qwerty</tns:keyCode>
      <tns:niNumber>NW123456D</tns:niNumber>
    </tns:validateNiNumber>
  </soap:Body>
</
soap:Envelope>

 

Below is a typical XML message response

<?xml version="1.0" encoding="utf-8"?>
<
soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <soap:Body>
    <validateNiNumberResponse xmlns="http://vtest.bemac.com/">
      <validateNiNumberResult>
        <valid>true</valid>
        <validity>Valid</validity>
        <number>NW123456D</number>
      </validateNiNumberResult>
    </validateNiNumberResponse>
  </soap:Body>
</
soap:Envelope>


 URL Encoding

Below is an example of using validateNiNumber via a URL encoded GET request:

  serviceUrl.asmx/ninumber2.aspx?keycode=qwerty&ninumber=NW123456D