![]() |
Web Development »
Validation »
General
Intermediate
SSN Validation Web ServiceBy tupacs01This article describes the implementation of an ASP.NET Web Service which can be used for SSN format validation. |
VB, XML.NET 1.1, Win2K, WinXP, Win2003, ASP.NET, Visual Studio, IIS 6, Dev
|
|
Advanced Search Add to IE Search |
|
|
|
||||||||||||||||

Being a big advocate of learning by doing, I decided to teach myself ASP.NET and ASP.NET Web Services by writing a simple application. This article walks through the process of designing a simple ASP.NET Web Service to address a business need.
Disclaimer #1 - The information provided in this article and computer code has been gathered from publicly available sources, including the United States Social Security Administration Website. I make no warranties, express or implied, as to the accuracy of this information.
Disclaimer #2 - SSN information is highly confidential. It should not be transmitted electronically in a non-secure format. This application is for educational purposes only.
To use the Web Service, just add a Web Reference to it in your Project. After you've added the Web reference, you can use it just like any other class:
Imports SsnValid
' ...
' Create a new SsnValidator object
Dim MyValidator As New SsnValid.SsnValidator
' Get the Results in an SsnResult variable
Dim MyResults As SsnValid.SsnResult = MyValidator.ValidateSsn(txtSsn.Text)
SsnValidator is the main class for the Web Service. It contains the public function .ValidateSsn() which performs the actual validation of the format of your SSN. The results are returned as an SsnResult structure. The SsnResult structure has four values: Code, Result, Comment and State which are explained in greater detail further down.
My first step in designing this Web Service was to define the business problem. For this example, I decided to validate the structure of Social Security Numbers (SSN's). I began by researching the subject thoroughly on the Social Security Administration Website. The SSA provides quite a lot of information for employers to use in determining the validity of SSN's.
I used the information available on the SSA website to determine the rules for SSN validity. This information includes:
Group Codes are assigned according to the following pattern:
As an example, for Area Number "277" (an Ohio code), the High Group Code is currently "08". This means that all odd numbers between 01 and 09, all even numbers between 10 and 98, and all even numbers between 02 and 06 are used up. New SSN's assigned from this area will have the format: 277-08-xxxx.
Now we decide what information we want to return. Based on the information available via the SSA website, I've decided on four fields:
Code: A numeric return code which will be easy for an application to decipher.
Result: The return code is in human-readable format.
Comment: A comment field which can give more detail regarding the return code.
State: The State/Geographic location responsible for issuing the SSN.The implementation of the Web Service is simple in nature, and the code is well-documented. I won�t go too deeply into it, other than to provide a simplified flowchart of the logic for the .ValidateSSN() function:

I�ve created an Access Database called Ssn.mdb which must be located in the project�s \bin directory. It contains information updated from the SSA website, effective 2/1/2004.
For me, the greatest point of interest was implementing the convoluted logic the government uses when assigning new SSN's. It made for some interesting development. Overall, I was pleasantly surprised at how easy it was to create a Web Service using ASP.NET. Originally I designed this Web Service to run against a SQL Server database, but downgraded it to Access to make this demonstration more portable. If there's enough interest, I can post the SQL Server/MSDE-capable version at a later date.
Initial release.
| You must Sign In to use this message board. | |||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||
General
News
Question
Answer
Joke
Rant
Admin
|
PermaLink |
Privacy |
Terms of Use
Last Updated: 6 Feb 2005 Editor: Sumalatha K.R. |
Copyright 2005 by tupacs01 Everything else Copyright © CodeProject, 1999-2009 Web20 | Advertise on the Code Project |