“PostZon” Geographic Data - SOAP API
To get a "Postzon" Geographical Data address from our SOAP Web Service we do the following:
The following example calls our server to retrieve the PostZon address data for a given postcode, OSRef, Longitude/Latitude or Town. It also returns the Distance in Km between two postcodes if HomePostcode is set.
Step 1 Add SOAP reference to your project
The following web references give access to our SOAP web service
.NET Web Reference
http://www.SimplyLookupadmin.co.uk/WebService.asmx
WSDL Web Reference
http://www.SimplyLookupadmin.co.uk/WebService.asmx?WSDL
You should add this SOAP reference to your project.
Step 2 Call SOAP Web Service to get PostZon Data
The following code will call the SOAP Web Service to return "Postzon" Geographical Data for a given postcode.
VB.Net |
Dim HomePostcode as string
="PE132QL" Dim PostcodeToGet as string = "PE132XQ" Dim PostcodeSearch As New PostcodeWebService.WebService Dim Address As PL_AddressRecord 'Ask for Address by ID Address = PostcodeSearch.SearchForPostZonData(“My DataKey”, “TestComputer", "UK", PostcodeToGet, HomePostcode) 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 + = "Longitude:" & .longitude_WGS84 & vbCrLf AddressText + = "Latitude:" & .latitude_WGS84 & vbCrLf AddressText + = "Distance Km:" & .GeoDistanceToHomePostcode & vbCrLf End With Me.TxtAddress.Text = AddressText Else 'Display error (Account stuff mostly, i.e. No License) MsgBox(Address.ErrorMessage) End If |
C# .NET |
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 postcode = Request.QueryString["postcode"].ToString(); string userid = Request.QueryString["userid"].ToString(); string homepostcode = Request.QueryString["homepostcode"].ToString(); //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." In simple language this means that each user must be identified by a unique username. //If the postcode address search is for External use then SET ComputerName = "" //Do Search, on Postcode or two or more address fields AddressesDataReturned = PostcodeSearch.SearchForPostZonData(datakey, userid, "UK", postcode, homepostcode); if (AddressesDataReturned.AddressRecordGotWithoutError == true) { //Display results, no major error this.TxtResults.Text = AddressesDataReturned.ErrorMessage; string AddressText; AddressText = "Status:" + AddressesDataReturned.CreditsStatusText + "\n" + "\n"; AddressText += "MailSort:" + AddressesDataReturned.MailSort + "\n"; AddressText += "longitude_WGS84:" + AddressesDataReturned.longitude_WGS84 + "\n"; AddressText += "latitude_WGS84:" + AddressesDataReturned.latitude_WGS84 + "\n"; AddressText += "UK_os_reference:" + AddressesDataReturned.UK_os_reference + "\n"; AddressText += "UK_OS_grid_east:" + AddressesDataReturned.UK_OS_grid_east + "\n"; AddressText += "UK_OS_grid_north:" + AddressesDataReturned.UK_OS_grid_north + "\n"; AddressText += "UK_NHS_code:" + AddressesDataReturned.UK_NHS_code + "\n"; AddressText += "UK_NHS_region:" + AddressesDataReturned.UK_NHS_region + "\n"; AddressText += "UK_country:" + AddressesDataReturned.UK_country + "\n"; AddressText += "UK_IntroductionDate:" + AddressesDataReturned.UK_IntroductionDate + "\n"; AddressText += "UK_county:" + AddressesDataReturned.UK_county + "\n"; AddressText += "UK_district:" + AddressesDataReturned.UK_district + "\n"; AddressText += "UK_ward:" + AddressesDataReturned.UK_ward + "\n"; AddressText += "UK_wardstatus:" + AddressesDataReturned.UK_wardstatus + "\n"; AddressText += "UK_county:" + AddressesDataReturned.UK_county + "\n"; AddressText += "UK_gridstatus:" + AddressesDataReturned.UK_gridstatus + "\n"; // long Distance = 0; // to do AddressesDataReturned.GeoDistanceToHomePostcode is a string and needs type casting? //If (length(AddressesDataReturned.GeoDistanceToHomePostcode)>0) Then // Distance = (long)(AddressesDataReturned.GeoDistanceToHomePostcode); // AddressText += "Distance:" + Distance + " km " + (long)(Distance / 1.609344) + " miles" + "\n"; this.TxtResults.Text = AddressText; } else { //Display error (Account stuff mostly) this.TxtResults.Text = AddressesDataReturned.ErrorMessage; } |
Where PostcodeSearch is a web reference to: http://www.SimplyLookupadmin.co.uk/WebService.asmx
Data Returned
See data returned by PostZon data
more information about getting distance/Longitude/Latitude using SOAP web service.
Related "Geographic" topics
Features | SOAP API |
HTTP/XML API | JSON API |
NET API. | Data Returned |
Download Example Code | Request a Quote and Brochure |
Open a 30 day evaluation account |