Integration of Location Services

Neova Solutions
2 min readMay 12, 2020

Location service is used to search and retrieve any address related to Airport or landmark information with multiple components like Countrycode, State, City, Postal Code, AddressLine, etc .

This service is created using the WCF framework and can be consumed by a variety of clients.

Location service architecture:

Location service features are exposed to the clients by means of Location interface. Within the service, this interface is implemented for business rules and parsing/validation in the business layer, which makes a call to database service for handling databases. Database service has been implemented using ADO.Net to communicate with the database and on receiving the data from the database, it will send this data as a response back to the business layer.

If the data is not there in response(as received from database), a request is sent to Google API and the response received by Google API is saved to the database and after parsing and validation, response is sent to the clients, else Google API call is skipped and the response from the database is sent to the clients.

Defining Location service Interface:

public interface ILocationService { [WsdlDocumentation("Get geocoding information based on the address search text.")] [return: WsdlParamOrReturnDocumentation("Returns DataTable containing specified address information.")] [OperationContract] DataTable GetAddressBySearchText ( [WsdlParamOrReturnDocumentation("Expects search string to find the street address.")] string SearchText ); }

Calling database layer methods from business logic:

//Invoking the Data layer service method to get the street address detailsDatabaseClient dbClient= new DatabaseClient();
dtSearchBasedAddresses = dbClient.GetAddressBySearchText(SearchText);
//returning the data table containing address details
return dtSearchBasedAddresses;

Example of database layer method

public DataTable GetAddressBySearchText(string SearchText)
{
try
{
//Create Db Connection
Database DBConnection = DBConnectionCertificate.GetDatabase();
using(DbCommand dbCommand= DBConnection.GetStoredProcCommand(Location_Addresses_SP, SearchText))
{
//Execute query.
DataSet dsAddresses = DBConnection.ExecuteDataSet(dbCommand);
return dsAddresses.Tables[0];
}
}
catch (Exception ex)
{
Faults.DataLayerExceptionFault objFault=new Faults.DataLayerExceptionFault(ex.Message.ToString());
throw new FaultException<Faults.DataLayerExceptionFault>(objFault,new FaultReason(ex.Message.ToString()));
}
}

Calling Google API:

1. For calling Google API, developers have to instantiate the URL by providing the expected inputs(like latitude, longitude etc) and Google API key.

var url = String.Format("{0}geocode/xml?latlng={1},{2}&sensor=false&client={3}",
ConfigurationManager.AppSettings["GoogleAPIUrl"], Latitude, Longitude, ConfigurationManager.AppSettings["GoogleClientID"]);

2.Next step is to convert the default base64 encoding in order to implement a URL safe version

url=GGA.Common.Security.GoogleSignedUrl.Sign(url,ConfigurationManager.AppSettings["GoogleSignatureKey"]);

3.Read the response

var geoCodeResponseXml = System.Xml.Linq.XElement.Load(url);
var status = geoCodeResponseXml.Element("status").Value;

Read more to know Features of Location Service

Originally published at https://www.neovasolutions.com on May 12, 2020.

--

--

Neova Solutions

We transform ideas into beautiful products. Since 2007, we are empowering startups to build disruptive products that are feature-rich and robust.