- C#
- Java
Address Geocode – International C# Code Snippet
//In the event that a production license key is purchased, these two variables should call sws.serviceobjects.com and swsbackup.serviceobjects.com respectively. string primaryURL = "https://trial.serviceobjects.com/agi/api.svc/json/PlaceSearch?Singleline=" + singleline + "&Address1=" + address1 + "&Address2=" + address2 + "&Address3" + address3 + "&Address4=" + address4 + "&Address5=" + address5 + "&Locality=" + locality + "&AdministrativeArea=" + administrativearea + "&PostalCode=" + postalcode + "&Country=" + country + "&Boundaries=" + boundaries + "&MaxResults=" + maxresults + "&SearchType=" + searchtype + "&Extras=" + extras + "&LicenseKey=" + licenseky; string backupURL = "https://trial.serviceobjects.com/agi/api.svc/json/PlaceSearch?Singleline=" + singleline + "&Address1=" + address1 + "&Address2=" + address2 + "&Address3" + address3 + "&Address4=" + address4 + "&Address5=" + address5 + "&Locality=" + locality + "&AdministrativeArea=" + administrativearea + "&PostalCode=" + postalcode + "&Country=" + country + "&Boundaries=" + boundaries + "&MaxResults=" + maxresults + "&SearchType=" + searchtype + "&Extras=" + extras + "&LicenseKey=" + licenseky; try { response = CallURL<SearchResponse>(primaryURL); if (response == null || (response.Error != null && response.Error.TypeCode == "3")) { throw new Exception(); } } catch { //Calling Backup URL. This should be set to swsbackup.serviceobjects.com when a production key is purchased. response = CallURL<SearchResponse>(backupURL); }
Address Geocode – International Java Code Snippet
//Get the input parameters from the form SingleLine = request.getParameter("iSingleLine"); Address1 = request.getParameter("iAddress1"); Address2 = request.getParameter("iAddress2"); Address3 = request.getParameter("iAddress3"); Address4 = request.getParameter("iAddress4"); Address5 = request.getParameter("iAddress5"); Locality = request.getParameter("iLocality"); AdministrativeArea = request.getParameter("iAdministrativeArea"); PostalCode = request.getParameter("iPostalCode"); Country = request.getParameter("iCountry"); Boundaries = request.getParameter("iBoundaries"); MaxResults = request.getParameter("iMaxResults"); SearchType = request.getParameter("iSearchType"); Extras = request.getParameter("iExtras"); LicenseKey = request.getParameter("iLicenseKey"); SearchResponse Response = null; AGIClient Client = new AGIClient(); try{ //Make a web request to the primary URL Response = Client.PlaceSearch(SingleLine, Address1, Address2, Address3, Address4, Address5, Locality, AdministrativeArea, PostalCode, Country, Boundaries, MaxResults, SearchType, Extras, LicenseKey); } catch(Exception r) { // Make a web request to the backup URL AGIClient backupClient = new AGIClient(); Response = backupClient.PlaceSearch(SingleLine, Address1, Address2, Address3, Address4, Address5, Locality, AdministrativeArea, PostalCode, Country, Boundaries, MaxResults, SearchType, Extras, LicenseKey); }