Postcode Programming API  Get Full Address from SOAP Web Service

Full Address Search functionality:

  1. Enter postcode to search for
  2. Presents a list of addresses at postcode entered
  3. Address is selected by user
  4. Full address for selection is returned

The following example calls our server to retrieve a list of addresses for a given postcode (or address words if using our Web Based data). These addresses are then displayed in a list box for user selection (step1), with line ID, then the full address is finally retrieved from our server in the next step (step2).

Step 1 Sign up for 30 day free trial

Simply use the "Sign Up for Trial" link at top right of this page to open a trial account.   We will then send you a data key, which is used to identify your account, when using the following service.

Step 2 Add SOAP reference to your project

The following web references give access to our SOAP web service

.NET Web Reference

https://www.SimplyLookupadmin.co.uk/WebService.asmx

WSDL Web Reference

https://www.SimplyLookupadmin.co.uk/WebService.asmx?WSDL

You should add this SOAP reference to your project.

Parameters

Parameter name Description
DataKey Datakey, which is available when account has been created, under the “DataKey” tab of the online account administrator page.
Username Only needed if for internal postcode address use
SearchType Set to “UK”
SearchPrima.Postcode Postcode to find
To retrieve residential property only. To do this simply append “[” to the end of the Postcode.
To retrieve commercial property only. To do this simply append “]” to the end of the Postcode.

Returns

Returns true if address search completed and General_credits_display_text contains summary of Credits/License status. Else errors reported in General_errormessage. 

Step 3 Call SOAP Web Service for Addresses at Postcode

The following code will call the SOAP Web Service to return a list of addresses given a postcode.  The list should be displayed to the user for selection.

Example Code


        VB.NET   
          
            'Search for full Postcode or other 
            address fields
Me.ListView1.Items.Clear()
Dim PostcodeSearch As New PostcodeWebService.WebService
Dim SearchPrima As New PL_SearchPrimaRecord
Dim AddressesDataReturned As New PL_AddressesDataReturnedRecord

'Set search criteria, either full Postcode or Two other address fields
With SearchPrima
   .Postcode = Me.InpPostcode.Text
End With

'Do Search, on Postcode or two or more address fields
AddressesDataReturned = PostcodeSearch.SearchForAddress("My DataKey", "UserID",
                     "UK", SearchPrima)


If AddressesDataReturned.SearchPerformedWithoutError Then
   'Display results, no major error
   If AddressesDataReturned.ErrorMessage <> "" Then MsgBox(AddressesDataReturned.ErrorMessage)

   With AddressesDataReturned
      'Show amount of Postocde Lookup credits left
      Me.Text = .CreditsStatusText

      'Remember the URL to buy more Postocde Lookup credits
      LinkToBuyMoreCredits = .BuyMoreCreditsURL
      Me.LinkTOBuyMore.Visible = True

      'Put Address data in listview
      Dim x&
      For x = 0 To .LineCount
         Dim itemToAdd As ListViewItem = ListView1.Items.Add(.Lines(x).ID, 0)
         itemToAdd.SubItems.Add(.Lines(x).Address)
      Next
   End With

   Me.TabControl1.SelectedIndex = 1
Else
   'Display error (Account stuff mostly)
   MsgBox(AddressesDataReturned.ErrorMessage)
End If


        C# .NET   
          
            string myDataKey = 
            Request.QueryString["datakey"].ToString();
string PostCode = Request.QueryString["postcode"].ToString();
string UserID = "UniqueID";

//Create PostcodeWebService.WebService object
uk.co.simplylookupadmin.www.WebService myWSObj = new uk.co.simplylookupadmin.www.WebService();

uk.co.simplylookupadmin.www.PL_SearchPrimaRecord myWSSearch =
                  new uk.co.simplylookupadmin.www.PL_SearchPrimaRecord();


uk.co.simplylookupadmin.www.PL_AddressesDataReturnedRecord myWSAddrRec =
                  new uk.co.simplylookupadmin.www.PL_AddressesDataReturnedRecord();


myWSSearch.Postcode = PostCode;
myWSAddrRec = myWSObj.SearchForAddress(myDataKey, UserID, "UK", myWSSearch);

//Show amount of Postocde Lookup credits left
this.Label2.Text = myWSAddrRec.CreditsStatusText;

if (myWSAddrRec.SearchPerformedWithoutError == true)
{
   for (int i = 0; i < myWSAddrRec.LineCount; i++)
   {
      ListBox1.Items.Add(new ListItem(myWSAddrRec.Lines[i].Address, myWSAddrRec.Lines[i].ID));
   }
}
else
{
   //Display error (Account stuff mostly)
   this.Label2.Text = myWSAddrRec.ErrorMessage;
}


Where uk.co.simplylookupadmin.www is a web reference to: https://www.SimplyLookupadmin.co.uk/WebService.asmx

  Please note: Section 3.5 of the terms and conditions state: "The Customer, when using the Postcode Lookup service via Web Service, must make sure each user is identified by a unique Computer name, in each call to the Web Service if used internally”. In simple language this means that each user must be identified by a unique computer name, if used by a company employee. In the above example "UserID" was passed as the computer name.

Step 4 Get Address Record

Having selected the address line from previous step, we now need to get the address record given the Address ID of record selected.

Parameters

Parameter name Description
DataKey Datakey, which is available when account has been created, under the “DataKey” tab of the online account administrator page.
Username Only needed if for internal postcode address use
SearchType Set to “UK”
AddressID Address ID of line selected in previous step

Example Code


        VB.NET   
          
            'Get ID from Listbox in hidden 
            column 0
Dim AddressID As String = ListView1.Items(ListView1.SelectedItems.Item(0).Index).SubItems(0).Text
Dim PostcodeSearch As New PostcodeWebService.WebService
Dim Address As PL_AddressRecord

'Ask for Address by ID
Address = PostcodeSearch.GetAddressRecord("My DataKey", "UserID", "UK", AddressID)

Me.TabControl1.SelectedIndex = 2

If Address.AddressRecordGotWithoutError Then
   'Display results
   If Address.ErrorMessage <> "" Then MsgBox(Address.ErrorMessage)

   'Process the Address to text field
   Dim AddressText As String
   With Address
      AddressText = "Company:" & .CompanyName & vbCrLf
      AddressText += "Line1:" & .Line1 & vbCrLf
      AddressText += "Line2:" & .Line2 & vbCrLf
      AddressText += "Line3:" & .Line3 & vbCrLf
      AddressText += "Town:" & .Town & vbCrLf
      AddressText += "Postcode:" & .PostZipcode & vbCrLf
      AddressText += "Country:" & .Country & vbCrLf
   End With
   Me.TxtAddress.Text = AddressText
Else
   'Display error (Account stuff mostly, i.e. No License)
   MsgBox(Address.ErrorMessage)
End If


        C# .NET   
          
             
            //Search for Address by 
              Postcode, but returning Thorughfare data
uk.co.simplylookupadmin.www.WebService PostcodeSearch = new uk.co.simplylookupadmin.www.WebService();
uk.co.simplylookupadmin.www.PL_AddressRecord AddressesDataReturned =
                              new uk.co.simplylookupadmin.www.PL_AddressRecord();


string datakey = Request.QueryString["datakey"].ToString();
string addressid = Request.QueryString["addressid"].ToString();
string userid = Request.QueryString["userid"].ToString();

//Do Search, on Postcode or two or more address fields
AddressesDataReturned = PostcodeSearch.GetAddressRecord(datakey, userid, "UK", addressid);

if (AddressesDataReturned.AddressRecordGotWithoutError == true)
{
   //Display results, no major error
   this.TxtResults.Text = AddressesDataReturned.ErrorMessage;

   string AddressText;
   AddressText = "Status:" + AddressesDataReturned.CreditsStatusText + "\n" + "\n";
   AddressText += "Company:" + AddressesDataReturned.CompanyName + "\n";
   AddressText += "Line1:" + AddressesDataReturned.Line1 + "\n";
   AddressText += "Line2:" + AddressesDataReturned.Line2 + "\n";
   AddressText += "Line3:" + AddressesDataReturned.Line3 + "\n";
   AddressText += "Town:" + AddressesDataReturned.Town + "\n";
   AddressText += "County:" + AddressesDataReturned.CountyState + "\n";
   AddressText += "PostCode:" + AddressesDataReturned.PostZipCode + "\n";
   AddressText += "Country:UK" + "\n";


   AddressText += "DeliveryPointSuffix:" + AddressesDataReturned.DeliveryPointSuffix + "\n";
   AddressText += "NoHouseHolds:" + AddressesDataReturned.NoHouseHolds + "\n";
   AddressText += "SmallOrg:" + AddressesDataReturned.SmallOrg + "\n";

   this.TxtResults.Text = AddressText;

}
else
{
   //Display error (Account stuff mostly)
   this.TxtResults.Text = AddressesDataReturned.ErrorMessage;
}



Step 5 Testing

Final step is to test, to enable easy testing please use our special test postcodes.

Postcode Software Full Address Search - Example Code 

Simply download the example code.   The code is in the "SOAP/VBNET 2010 FULL PAFF" or "SOAP/VBNET 2003 FULL PAFF" directory of our example downloads.

These two examples demonstrate postcode lookup software using Full Address.

Data Returned:

General Information

Public AddressRecordGotWithoutError As Boolean
    'True if address data returned
Public ErrorMessage As String
    'Shows number of Credits/Users available
Public ErrorMessage As String
    'Error Message if error
Public BuyMoreCreditsURL As String
    'URL which takes use to buy more credits

PAF Address Information

Public Id As String  
Public CompanyName As String
Public Line1 As String
Public Line2 As String
Public Line3 As String
Public Town As String
Public CountyState As String
Public PostZipCode As String
Public Country As String


'Note: When using getting Thoroughfare only:
    'CompanyName is Not returned
    'Line1 may return road name, but the user must supply the Building 
    'Name/Number in your software, so you will need to prompt them for this data

'Extra Address information contained in PAF data file
Public DeliveryPointSuffix As String  
Public NoHouseHolds As String  

Public SmallOrg As String  

Public MailSort As String 
  
Public Unique As String     
Public UDPRN As String    

Public Spare As String     

   see Additional Data Returned by Postcode Finder API for more information